當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。