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


Python DBSession.configure方法代码示例

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


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

示例1: main

# 需要导入模块: from pi_director.models.models import DBSession [as 别名]
# 或者: from pi_director.models.models.DBSession import configure [as 别名]
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    with transaction.manager:
        model = RasPi()
        model.uuid = '11:22:33:44:55:66'
        model.description = "Testing Pi"
        model.url = "http://www.facebook.com"
        model.orientation = 0
        model.browser = True
        model.lastseen = datetime.now()
        DBSession.add(model)

        tag = Tags()
        tag.uuid = '11:22:33:44:55:66'
        tag.tag = 'test'
        DBSession.add(tag)

        User = UserModel()
        User.email = '[email protected]'
        User.AccessLevel = 2
        DBSession.add(User)

    DBSession.flush()
开发者ID:PeterGrace,项目名称:pi_director,代码行数:33,代码来源:initializedb.py

示例2: main

# 需要导入模块: from pi_director.models.models import DBSession [as 别名]
# 或者: from pi_director.models.models.DBSession import configure [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    NotSoSecret = 'CIeUz0RK8fjRq1wJSrID'
    authn_policy = AuthTktAuthenticationPolicy(NotSoSecret,
                                               callback=groupfinder,
                                               hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()
    session_factory = SignedCookieSessionFactory(NotSoSecret)

    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    config = Configurator(settings=settings, root_factory=Root)
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)
    config.include('velruse.providers.google_oauth2')
    config.set_session_factory(session_factory)
    config.add_google_oauth2_login_from_settings(prefix='velruse.google.')
    config.include('cornice')
    config.include('pyramid_mako')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_static_view('client_agent', 'client_agent', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('tagged', '/tagged/{tags}')
    config.add_route('users', '/users')
    config.add_route('logout', '/logout')
    config.add_route('redirectme', '/go/{uid}')
    config.add_route('provision', '/provision')
    config.add_route('logs', '/logs/{uuid}')
    config.add_route('wall', '/wall/{tags}')
    config.add_request_method(LookupUser, 'user', reify=True)
    config.scan()
    return config.make_wsgi_app()
开发者ID:PeterGrace,项目名称:pi_director,代码行数:36,代码来源:__init__.py

示例3: setUp

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

示例4: main

# 需要导入模块: from pi_director.models.models import DBSession [as 别名]
# 或者: from pi_director.models.models.DBSession import configure [as 别名]
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)
    engine = engine_from_config(settings, "sqlalchemy.")
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    with transaction.manager:
        model = RasPi(uuid="default", url="http://www.facebook.com")
        DBSession.add(model)
开发者ID:selfcommit,项目名称:pi_director,代码行数:15,代码来源:initializedb.py


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