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


Python Session.configure方法代码示例

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


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

示例1: setup_connection_and_db_from_config

# 需要导入模块: from mediagoblin.db.base import Session [as 别名]
# 或者: from mediagoblin.db.base.Session import configure [as 别名]
def setup_connection_and_db_from_config(app_config, migrations=False, app=None):
    engine = create_engine(app_config['sql_engine'])

    # @@: Maybe make a weak-ref so an engine can get garbage
    # collected?  Not that we expect to make a lot of MediaGoblinApp
    # instances in a single process...
    engine.app = app

    # Enable foreign key checking for sqlite
    if app_config['sql_engine'].startswith('sqlite://'):
        if migrations:
            event.listen(engine, 'connect',
                         _sqlite_disable_fk_pragma_on_connect)
        else:
            event.listen(engine, 'connect', _sqlite_fk_pragma_on_connect)

    # logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)

    if DISABLE_GLOBALS:
        return DatabaseManager(engine)

    else:
        Session.configure(bind=engine)

        return DatabaseMaster(engine)
开发者ID:ausbin,项目名称:mediagoblin,代码行数:27,代码来源:open.py

示例2: setup_connection_and_db_from_config

# 需要导入模块: from mediagoblin.db.base import Session [as 别名]
# 或者: from mediagoblin.db.base.Session import configure [as 别名]
def setup_connection_and_db_from_config(app_config, migrations=False):
    engine = create_engine(app_config['sql_engine'])

    # Enable foreign key checking for sqlite
    if app_config['sql_engine'].startswith('sqlite://'):
        if migrations:
            event.listen(engine, 'connect',
                         _sqlite_disable_fk_pragma_on_connect)
        else:
            event.listen(engine, 'connect', _sqlite_fk_pragma_on_connect)

    # logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)

    Session.configure(bind=engine)

    return DatabaseMaster(engine)
开发者ID:goblinrefuge,项目名称:goblinrefuge-mediagoblin,代码行数:18,代码来源:open.py

示例3: setup_connection_and_db_from_config

# 需要导入模块: from mediagoblin.db.base import Session [as 别名]
# 或者: from mediagoblin.db.base.Session import configure [as 别名]
def setup_connection_and_db_from_config(app_config):
    engine = create_engine(app_config['sql_engine'])
    # logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
    Session.configure(bind=engine)

    return DatabaseMaster(engine)
开发者ID:orblivion,项目名称:mediagoblin-quickstart-openshift,代码行数:8,代码来源:open.py


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