Exemple #1
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
Exemple #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
Exemple #3
0
 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()
Exemple #4
0
 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()
Exemple #5
0
def get_session():
    return db_session.get_session(sqlite_fk=True)
Exemple #6
0
def get_session():
    return db_session.get_session(sqlite_fk=True)