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


Python DBSession.configure方法代码示例

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

示例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()
开发者ID:arnaud-morvan,项目名称:v6_api,代码行数:35,代码来源:__init__.py

示例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)
开发者ID:c2corg,项目名称:v6_api,代码行数:14,代码来源:initializedb.py

示例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()
开发者ID:arnaud-morvan,项目名称:v6_api,代码行数:17,代码来源:scheduler.py

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


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