当前位置: 首页>>代码示例>>Python>>正文


Python DBSession.configure方法代码示例

本文整理汇总了Python中models.DBSession.configure方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.configure方法的具体用法?Python DBSession.configure怎么用?Python DBSession.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.DBSession的用法示例。


在下文中一共展示了DBSession.configure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_db

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import configure [as 别名]
def init_db(config_path):
    setup_logging(config_path)
    settings = get_appsettings(config_path)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    print 'Done'
开发者ID:pytlakp,项目名称:intranet-1,代码行数:9,代码来源:script.py

示例2: main

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import configure [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    LOG.debug("settings:{}".format(settings))
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    config = Configurator(settings=settings)
    config.include('pyramid_chameleon')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_static_view('jasny-css', 'static/jasny-bootstrap/css', cache_max_age=3600)
    config.add_static_view('jasny-js', 'static/jasny-bootstrap/js', cache_max_age=3600)
    config.add_route('login', '/')
    config.add_route('logout', '/logout')
    config.add_route('show_empl', '/employee/{emp_no}',
                     factory=EmployeeRootFactory)
    config.add_route('show_dept', '/department/{dept_no}',
                     factory=DeptRootFactory)

    auth_engine = AuthEngine()
    config.add_settings(auth_engine=auth_engine)
    authn_policy = AuthTktAuthenticationPolicy(settings['secret_key'],
                                               callback=auth_engine.get_groups,
                                               hashalg='sha512')
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(ACLAuthorizationPolicy())

    query_parser = FormQueryParser()
    config.add_settings(query_parser=query_parser)

    config.scan()

    return config.make_wsgi_app()
开发者ID:lseek,项目名称:empdb,代码行数:35,代码来源:__init__.py

示例3: main

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import configure [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    
    load_project_settings()
    
    session_factory = UnencryptedCookieSessionFactoryConfig(settings.get('session.secret', 'hello'))
    
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    config = Configurator(session_factory=session_factory, settings=settings)
    config.include('pyramid_handlers')
    config.add_view('pyramid.view.append_slash_notfound_view',
                context='pyramid.httpexceptions.HTTPNotFound')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('status', '/status')
    config.add_route('settings', '/settings')
    
    
    configure_app_routes(config)
    
    config.scan()
    
    return config.make_wsgi_app()
开发者ID:ayesha928,项目名称:fyp,代码行数:27,代码来源:__init__.py

示例4: main

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import configure [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """

    load_project_settings()

    session_factory = UnencryptedCookieSessionFactoryConfig(settings.get('session.secret', 'hello'))

    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    config = Configurator(session_factory=session_factory, settings=settings)
    config.add_tween('giteverywhere.auth.authenticator')
    config.include('pyramid_handlers')
    config.add_view('pyramid.view.append_slash_notfound_view',
                context='pyramid.httpexceptions.HTTPNotFound')
    config.add_static_view('static', 'static', cache_max_age=3600)

    config.add_route('home', '/')
    config.add_route('contact', '/contact')
    config.add_route('pyckauth_login', '/login')
    config.add_route('pyckauth_logout', '/logout')
    config.add_route('pyckauth_manager', '/auth')
    config.add_route('pyckauth_users', '/auth/users')
    config.add_route('pyckauth_permissions', '/auth/permissions')
    config.add_route('pyckauth_routes', '/auth/routes')
   


    add_admin_handler(config, DBSession, get_models(giteverywhere), 'admin.', '/admin', AdminController)  
    configure_app_routes(config)

    config.scan()

    return config.make_wsgi_app()
开发者ID:giteverywhere,项目名称:giteverywhere,代码行数:36,代码来源:__init__.py

示例5: main

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import configure [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    config = Configurator(settings=settings)
    config.include('pyramid_mako')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('index', '/')
    config.add_route('accueil', '/accueil')
    config.add_route('map', '/map')
    config.add_route('map_stop', '/map/{stop_id}')
    config.add_route('form_stop', '/form/{stop_id}')
    config.add_route('trip', '/trip/{trip_id}')
    config.add_route('test', '/test')
    config.add_route('test_map', '/test_map')
    config.add_route('stop_stop', '/stop/{stop_id}')
    config.add_route('savoir', '/savoir')
    config.add_route('json_stop', '/json_stop')
    config.add_route('json_stops', '/json_stops')
    config.add_route('json_hor', '/json_hor')
    config.add_route('json_map', '/json_map')
    config.add_route('json_form', '/json_form')
    config.add_route('json_trip', '/json_trip')
    config.scan()
    return config.make_wsgi_app()
开发者ID:philippechataignon,项目名称:easytan,代码行数:28,代码来源:__init__.py

示例6: main

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import configure [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    session_factory = UnencryptedCookieSessionFactoryConfig("lolololseekret")
    config = Configurator(settings=settings, session_factory=session_factory)
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_static_view('graphs', 'graphs')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('meal', '/meals/{date}')
    config.add_route('meal_edit', '/meals/edit/{date}')
    config.add_route('weight', '/weight')
    config.add_route('weight_add', '/weight/add/')
    config.add_route('home', '/')
    config.add_route('chat_add', '/chat/add')
    config.add_route('note_add', '/notes/add')
    config.add_route('workout', '/workouts/{date}')
    config.add_route('workout_edit', 'workouts/edit/{date}')
    config.add_route('recipe', '/recipes')
    config.add_route('recipe_view', '/recipes/{id}')
    config.add_route('recipe_add', '/recipes/add')
    config.scan()
    return config.make_wsgi_app()
开发者ID:kyphelps,项目名称:Health-Tracker,代码行数:27,代码来源:__init__.py

示例7: setUp

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import configure [as 别名]
 def setUp(self):
     self.config = testing.setUp()
     from sqlalchemy import create_engine
     engine = create_engine('sqlite://')
     from .models import (
         Base,
         MyModel,
         )
     DBSession.configure(bind=engine)
开发者ID:mkprz,项目名称:bakshi,代码行数:11,代码来源:tests.py

示例8: main

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import configure [as 别名]
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
开发者ID:KenjiTakahashi,项目名称:intranet,代码行数:11,代码来源:initializedb.py

示例9: setUp

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import configure [as 别名]
 def setUp(self):
     self.config = testing.setUp()
     from sqlalchemy import create_engine
     engine = create_engine('sqlite://')
     from models import Base, MyModel
     DBSession.configure(bind=engine)
     Base.metadata.create_all(engine)
     with transaction.manager:
         model = MyModel(name='one', value=55)
         DBSession.add(model)
开发者ID:vice-versa,项目名称:mysacrud,代码行数:12,代码来源:test_views.py

示例10: main

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import configure [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """

    if not 'pyramid.secretcookie' in settings:
        log.error('pyramid.secretcookie is not set. Refusing to start.')
        quit(-1)

    if not 'pyramid.auth.secret' in settings:
        log.error('pyramid.auth.secret is not set. Refusing to start.')
        quit(-1)

    if not 'defcne.upload_path' in settings:
        log.error('defcne.upload_path is not set. Refusing to start.')
        quit(-1)

    if not 'defcne.registration_open' in settings:
        log.error('defcne.registration_open is not set. Refusing to start.')
        quit(-1)
    else:
        settings['defcne.registration_open'] = asbool(settings['defcne.registration_open'])

    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    config = Configurator(settings=settings)

    _session_factory = SignedCookieSessionFactory(
            settings['pyramid.secretcookie'],
            httponly=True,
            max_age=864000
            )

    _authn_policy = AuthTktAuthenticationPolicy(
            settings['pyramid.auth.secret'],
            max_age=864000,
            http_only=True,
            debug=True,
            hashalg='sha512',
            callback=auth.user_groups,
            )

    _authz_policy = ACLAuthorizationPolicy()

    config.set_session_factory(_session_factory)
    config.set_authentication_policy(_authn_policy)
    config.set_authorization_policy(_authz_policy)
    config.include(add_routes)
    config.include(add_views)
    config.include(add_events)

    deform_bootstrap.includeme(config)

    config.set_request_property(auth.current_user, 'user', reify=True)
    config.include('pyramid_mailer')
    return config.make_wsgi_app()
开发者ID:bertjwregeer,项目名称:defcne,代码行数:57,代码来源:__init__.py

示例11: main

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import configure [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    init_model()

    session_factory = session_factory_from_settings(settings)
    if 'localization' not in settings:
        settings['localization'] = 'id_ID.UTF-8'
    locale.setlocale(locale.LC_ALL, settings['localization'])        
    if 'timezone' not in settings:
        settings['timezone'] = DefaultTimeZone
    config = Configurator(settings=settings,
                          root_factory='reklame.models.RootFactory',
                          session_factory=session_factory)
    config.include('pyramid_beaker')                          
    config.include('pyramid_chameleon')

    authn_policy = AuthTktAuthenticationPolicy('sosecret',
                    callback=group_finder, hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()                          
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)
    config.add_request_method(get_user, 'user', reify=True)
    config.add_request_method(get_title, 'title', reify=True)
    config.add_notfound_view(RemoveSlashNotFoundViewFactory())        
                          
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_static_view('deform_static', 'deform:static')
    config.add_static_view('files', settings['static_files'])    
    ############################################################################
    config.include('pyramid_rpc.jsonrpc') # JSON RPC
    json_renderer = JSON()
    json_renderer.add_adapter(datetime.datetime, lambda v, request: v.isoformat())
    json_renderer.add_adapter(datetime.date, lambda v, request: v.isoformat())
    config.add_renderer('myjson', json_renderer)
    config.add_jsonrpc_endpoint('ws_reklame', '/ws/reklame', default_renderer="myjson")       
    ############################################################################
 
    routes = DBSession.query(Route.kode, Route.path, Route.nama).all()
    for route in routes:
        config.add_route(route.kode, route.path)
        if route.nama:
            titles[route.kode] = ' - '.join([main_title, route.nama])     
            
    
    config.scan()
    
    app = config.make_wsgi_app()
    from paste.translogger import TransLogger
    app = TransLogger(app, setup_console_handler=False)    
    return app
开发者ID:aagusti,项目名称:opensipkd-reklame,代码行数:56,代码来源:__init__.py

示例12: main

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import configure [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """

    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    config = Configurator(settings=settings)
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.scan()
    return config.make_wsgi_app()
开发者ID:5aket,项目名称:cpfthw,代码行数:13,代码来源:__init__.py

示例13: main

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import configure [as 别名]
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, "sqlalchemy.")
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine, check=True)
    with transaction.manager:
        model = Page("FrontPage", "This is the front page")
        DBSession.add(model)
开发者ID:Dante83,项目名称:lexinomicon,代码行数:14,代码来源:initialize_db.py

示例14: main

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import configure [as 别名]
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    with transaction.manager:
        model = BadCase(url='one')
        DBSession.add(model)
开发者ID:jwfing,项目名称:badreporter,代码行数:14,代码来源:initializedb.py

示例15: setUp

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import configure [as 别名]
    def setUp(self):
        self.config = testing.setUp()

        # @TODO change this
        from . import main
        settings = {'sqlalchemy.url': 'sqlite://', 'session.secret': 'secret'}
        app = main({}, **settings)
        self.testapp = TestApp(app)

        engine = create_engine('sqlite://')
        DBSession.configure(bind=engine)
        Base.metadata.create_all(engine)
开发者ID:ErwanTremiot,项目名称:notejam,代码行数:14,代码来源:tests.py


注:本文中的models.DBSession.configure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。