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


Python sqlalchemy.ZopeTransactionExtension方法代码示例

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


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

示例1: make_session

# 需要导入模块: from zope import sqlalchemy [as 别名]
# 或者: from zope.sqlalchemy import ZopeTransactionExtension [as 别名]
def make_session(transaction=True, autoflush=False, autocommit=False):
    # Yeah the arguments and their naming is so terrible. sorry
    config = ConfigParser.ConfigParser()
    config.read('production.ini')
    db_url = os.environ.get("FANTASYDOTA_DB")
    engine = create_engine(db_url, echo=False)
    if transaction:
        DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
    else:
        DBSession = sessionmaker(autoflush=autoflush, autocommit=autocommit)
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    Base.metadata.create_all(engine)
    session = DBSession()
    return session 
开发者ID:ThePianoDentist,项目名称:fantasy-dota-heroes,代码行数:17,代码来源:session_utils.py

示例2: main

# 需要导入模块: from zope import sqlalchemy [as 别名]
# 或者: from zope.sqlalchemy import ZopeTransactionExtension [as 别名]
def main(global_config, **main_settings):
        app_config = Config(global_config["__file__"])
        app_config.read()
        mm_settings = app_config["mishmash"]

        engine_args = dict(database.DEFAULT_ENGINE_ARGS)
        pfix, plen = "sqlalchemy.", len("sqlalchemy.")
        # Strip prefix and remove url value
        sql_ini_args = {
                name[plen:]: mm_settings[name]
                for name in mm_settings
                if name.startswith(pfix) and not name.endswith(".url")
        }
        engine_args.update(sql_ini_args)

        (engine,
         SessionMaker,
         connection) = database.init(app_config.db_url,
                                     engine_args=engine_args, scoped=True,
                                     trans_mgr=ZopeTransactionExtension())

        pyra_config = _configure(main_settings, SessionMaker)
        return pyra_config.make_wsgi_app() 
开发者ID:nicfit,项目名称:MishMash,代码行数:25,代码来源:__init__.py

示例3: initialize_sql

# 需要导入模块: from zope import sqlalchemy [as 别名]
# 或者: from zope.sqlalchemy import ZopeTransactionExtension [as 别名]
def initialize_sql(settings):
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)

    # Here, we configure our transaction manager to keep the session open
    # after a commit.
    # - This of course means that we need to manually close the session when
    #   we are done.
    DBSession.configure(extension=ZopeTransactionExtension())

    Base.metadata.create_all(engine) 
开发者ID:NOAA-ORR-ERD,项目名称:OilLibrary,代码行数:13,代码来源:initializedb.py

示例4: __init__

# 需要导入模块: from zope import sqlalchemy [as 别名]
# 或者: from zope.sqlalchemy import ZopeTransactionExtension [as 别名]
def __init__(self, db_path):
        self.base   = declarative_base()
        self.engine = create_engine(db_path, convert_unicode=True, pool_size=100)

        #self.base.prepare(self.engine, reflect=True)
        self.session = scoped_session(sessionmaker(bind=self.engine, twophase=True, extension=ZopeTransactionExtension()))
        #self.session = scoped_session(sessionmaker(bind=self.engine))

        register(self.session, keep_session=True) 
开发者ID:Cightline,项目名称:voat,代码行数:11,代码来源:db_connect.py

示例5: make_session_maker

# 需要导入模块: from zope import sqlalchemy [as 别名]
# 或者: from zope.sqlalchemy import ZopeTransactionExtension [as 别名]
def make_session_maker(zope_tr=True, autoflush=True):
    return scoped_session(sessionmaker(
        autoflush=autoflush,
        extension=ZopeTransactionExtension() if zope_tr else None)) 
开发者ID:conversence,项目名称:idealoom,代码行数:6,代码来源:sqla.py

示例6: is_zopish

# 需要导入模块: from zope import sqlalchemy [as 别名]
# 或者: from zope.sqlalchemy import ZopeTransactionExtension [as 别名]
def is_zopish():
    return isinstance(
        _session_maker.session_factory.kw.get('extension'),
        ZopeTransactionExtension) 
开发者ID:conversence,项目名称:idealoom,代码行数:6,代码来源:sqla.py


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