示例#1
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()
示例#2
0
文件: api.py 项目: trevenen/neutron
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)
示例#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)