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


Python DBSession.configure方法代码示例

本文整理汇总了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)
开发者ID:baloon11,项目名称:npui,代码行数:27,代码来源:rtd.py

示例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)
开发者ID:baloon11,项目名称:npui,代码行数:12,代码来源:dropdb.py

示例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)
开发者ID:annndrey,项目名称:npui,代码行数:15,代码来源:tests.py

示例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
	)
开发者ID:baloon11,项目名称:npui,代码行数:17,代码来源:__init__.py

示例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
开发者ID:unikmhz,项目名称:npui,代码行数:19,代码来源:__init__.py

示例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()
开发者ID:baloon11,项目名称:npui,代码行数:22,代码来源:genldif.py


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