def session_scope(self):
        """Provide a transactional scope around a series of operations."""
        session = self.session()
        try:
            yield session
            session.commit()
        except Exception as e:
            session.rollback()
            raise e
        finally:
            session.close()
def session_scope ( self ) : session = self . session ( ) try : yield session session . commit ( ) except Exception as e : session . rollback ( ) raise e finally : session . close ( )
Provide a transactional scope around a series of operations.