本文整理汇总了Python中netprofile.db.connection.DBSession.configure方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.configure方法的具体用法?Python DBSession.configure怎么用?Python DBSession.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类netprofile.db.connection.DBSession
的用法示例。
在下文中一共展示了DBSession.configure方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from netprofile.db.connection import DBSession [as 别名]
# 或者: from netprofile.db.connection.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)
cache.cache = cache.configure_cache(settings)
config = Configurator(
settings=settings,
root_factory=RootFactory,
locale_negotiator=locale_neg
)
config.add_route_predicate('vhost', VHostPredicate)
config.add_view_predicate('vhost', VHostPredicate)
mmgr = config.registry.getUtility(IModuleManager)
mmgr.load('core')
mmgr.load_enabled()
rts = rt.configure(mmgr, config.registry)
app = rts.app()
rt.run(rts, app)
示例2: main
# 需要导入模块: from netprofile.db.connection import DBSession [as 别名]
# 或者: from netprofile.db.connection.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)
ModuleManager.prepare()
Base.metadata.drop_all(engine)
示例3: setUp
# 需要导入模块: from netprofile.db.connection import DBSession [as 别名]
# 或者: from netprofile.db.connection.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)
示例4: setup_config
# 需要导入模块: from netprofile.db.connection import DBSession [as 别名]
# 或者: from netprofile.db.connection.DBSession import configure [as 别名]
def setup_config(settings):
global inst_id
settings['netprofile.debug'] = asbool(settings.get('netprofile.debug'))
if 'netprofile.instance_id' in settings:
inst_id = settings.get('netprofile.instance_id')
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
cache.cache = cache.configure_cache(settings)
return Configurator(
settings=settings,
root_factory=RootFactory,
locale_negotiator=locale_neg
)
示例5: setup_config
# 需要导入模块: from netprofile.db.connection import DBSession [as 别名]
# 或者: from netprofile.db.connection.DBSession import configure [as 别名]
def setup_config(settings):
global inst_id
settings['netprofile.debug'] = asbool(settings.get('netprofile.debug'))
if 'netprofile.instance_id' in settings:
inst_id = settings.get('netprofile.instance_id')
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
cache.cache = cache.configure_cache(settings)
config = Configurator(settings=settings,
root_factory=RootFactory,
locale_negotiator=locale_neg)
config.add_route_predicate('vhost', VHostPredicate)
config.add_view_predicate('vhost', VHostPredicate)
config.include('netprofile.common.crypto')
return config
示例6: main
# 需要导入模块: from netprofile.db.connection import DBSession [as 别名]
# 或者: from netprofile.db.connection.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)
cache.cache = cache.configure_cache(settings)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
config = Configurator(
settings=settings,
root_factory=RootFactory
)
mmgr = config.registry.getUtility(IModuleManager)
mmgr.load('core')
mmgr.load_enabled()
mb = mmgr.get_module_browser()