Beispiel #1
0
 def save(self, session=None):
     """Save this object."""
     if not session:
         session = sa.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()
Beispiel #2
0
 def save(self, session=None):
     """Save this object."""
     if not session:
         session = sa.get_session()
     # NOTE(boris-42): This part of code should be look like:
     #                       session.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
     #                 explicitly.
     with session.begin(subtransactions=True):
         session.add(self)
         session.flush()
Beispiel #3
0
def get_session(autocommit=True, expire_on_commit=False):
    """Helper method to grab session."""
    return session.get_session(autocommit=autocommit,
                               expire_on_commit=expire_on_commit,
                               sqlite_fk=True)