本文整理汇总了Python中c2corg_api.models.DBSession.configure方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.configure方法的具体用法?Python DBSession.configure怎么用?Python DBSession.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c2corg_api.models.DBSession
的用法示例。
在下文中一共展示了DBSession.configure方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from c2corg_api.models import DBSession [as 别名]
# 或者: from c2corg_api.models.DBSession import configure [as 别名]
def setUp(self): # noqa
self.app = TestApp(self.app)
registry = self.app.app.registry
self.mailer = get_mailer(registry)
self.email_service = EmailService(self.mailer, settings)
EmailService.instance = None
self.config = testing.setUp()
self.connection = self.engine.connect()
# begin a non-ORM transaction
self.trans = self.connection.begin()
# DBSession is the scoped session manager used in the views,
# reconfigure it to use this test's connection
DBSession.configure(bind=self.connection)
# create a session bound to the connection, this session is the one
# used in the test code
self.session = self.Session(bind=self.connection)
self.queue_config = registry.queue_config
reset_queue(self.queue_config)
reset_cache_key()
示例2: main
# 需要导入模块: from c2corg_api.models import DBSession [as 别名]
# 或者: from c2corg_api.models.DBSession import configure [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
# Configure SQLAlchemy
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
# Configure ElasticSearch
configure_es_from_config(settings)
config = Configurator(settings=settings)
config.include('cornice')
config.registry.queue_config = get_queue_config(settings)
bypass_auth = False
if 'noauthorization' in settings:
bypass_auth = asbool(settings['noauthorization'])
if not bypass_auth:
config.include("pyramid_jwtauth")
# Intercept request handling to validate token against the database
config.add_tween('c2corg_api.jwt_database_validation_tween_factory')
# Inject ACLs
config.set_root_factory(RootFactory)
else:
log.warning('Bypassing authorization')
# Scan MUST be the last call otherwise ACLs will not be set
# and the permissions would be bypassed
config.scan(ignore='c2corg_api.tests')
return config.make_wsgi_app()
示例3: main
# 需要导入模块: from c2corg_api.models import DBSession [as 别名]
# 或者: from c2corg_api.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)
alembic_config = Config(alembic_configfile)
setup_db(alembic_config, DBSession)
示例4: main
# 需要导入模块: from c2corg_api.models import DBSession [as 别名]
# 或者: from c2corg_api.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.bind = engine
configure_scheduler_from_config(settings)
signal.pause()
示例5: setup_package
# 需要导入模块: from c2corg_api.models import DBSession [as 别名]
# 或者: from c2corg_api.models.DBSession import configure [as 别名]
def setup_package():
# set up database
engine = get_engine()
DBSession.configure(bind=engine)
alembic_config = _get_alembic_config()
downgrade(alembic_config, 'base')
initializedb.setup_db(alembic_config, DBSession)
# set up ElasticSearch
configure_es_from_config(settings)
initializees.drop_index()
initializees.setup_es()
# Add test data needed for all tests
with transaction.manager:
_add_global_test_data(DBSession)
fill_index(DBSession)
DBSession.remove()