コード例 #1
0
ファイル: api.py プロジェクト: jsomara/tuskar
def model_query(model, *args, **kwargs):
    """Query helper for simpler session usage.

    :param session: if present, the session to use
    """

    session = kwargs.get('session') or db_session.get_session()
    query = session.query(model, *args)
    return query
コード例 #2
0
def model_query(model, *args, **kwargs):
    """Query helper for simpler session usage.

    :param session: if present, the session to use
    """

    session = kwargs.get('session') or db_session.get_session()
    query = session.query(model, *args)
    return query
コード例 #3
0
ファイル: models.py プロジェクト: ccrouch/tuskar
 def save(self, session=None):
     """Save this object."""
     if not session:
         session = get_session()
     # NOTE(boris-42): This part of code should be look like:
     #                       sesssion.add(self)
     #                       session.flush()
     #                 But there is a bug in sqlalchemy and eventlet that
     #                 raises NoneType exception if there is no running
     #                 transaction and rollback is called. As long as
     #                 sqlalchemy has this bug we have to create transaction
     #                 explicity.
     with session.begin(subtransactions=True):
         session.add(self)
         session.flush()
コード例 #4
0
ファイル: models.py プロジェクト: pombredanne/tuskar
 def save(self, session=None):
     """Save this object."""
     if not session:
         session = get_session()
     # NOTE(boris-42): This part of code should be look like:
     #                       sesssion.add(self)
     #                       session.flush()
     #                 But there is a bug in sqlalchemy and eventlet that
     #                 raises NoneType exception if there is no running
     #                 transaction and rollback is called. As long as
     #                 sqlalchemy has this bug we have to create transaction
     #                 explicity.
     with session.begin(subtransactions=True):
         session.add(self)
         session.flush()
コード例 #5
0
ファイル: api.py プロジェクト: jsomara/tuskar
def get_session():
    return db_session.get_session(sqlite_fk=True)
コード例 #6
0
ファイル: sqlalchemy.py プロジェクト: erictchiu/tuskar
def get_session():
    return db_session.get_session(sqlite_fk=True)