Exemplo n.º 1
0
 def delete(self):
     db_session = DbSession()
     try:
         db_session.delete(self)
         db_session.commit()
     except InvalidRequestError as e:
         self.__cleanupDbSession(db_session, self.__class__.__name__)
     except Exception as e:
         db_session.rollback()
         self.__logger.error(
             "Could not delete from {} table in database".format(
                 self.__tablename__),
             exc_info=True)
         raise DbException(
             "Could not delete from {} table in database".format(
                 self.__tablename__))
Exemplo n.º 2
0
 def delete(self):
     db_session = DbSession()
     db_session.expire_on_commit = True
     try:
         db_session.delete(self)
         db_session.commit()
         # Keep it detached
         make_transient(self)
         make_transient_to_detached(self)
     except InvalidRequestError as e:
         self.__cleanupDbSession(db_session, self.__class__.__name__)
     except Exception as e:
         db_session.rollback()
         self.logger.error(
             "Could not delete from {} table in database".format(
                 self.__tablename__),
             exc_info=True)
         raise DbException(
             "Could not delete from {} table in database".format(
                 self.__tablename__))