def delete(self, item): before_delete.send(self.resource, item=item) session = self._get_session() session.delete(item) session.commit() after_delete.send(self.resource, item=item)
def delete(self, item, commit=True): session = self._get_session() before_delete.send(self.resource, item=item) try: session.delete(item) self.commit_or_flush(commit) except IntegrityError as e: session.rollback() if current_app.debug: raise BackendConflict(debug_info=dict(exception_message=str(e), statement=e.statement, params=e.params)) raise BackendConflict() after_delete.send(self.resource, item=item)
def delete(self, item): session = self._get_session() with session.begin_nested(): before_delete.send(self.resource, item=item) try: session.delete(item) session.flush() except IntegrityError as exc: if current_app.debug: raise BackendConflict( debug_info=dict( exception_message=str(exc), statement=exc.statement, params=exc.params, ) ) from exc raise BackendConflict() from exc after_delete.send(self.resource, item=item)
def delete(self, item): before_delete.send(self.resource, item=item) item.delete() after_delete.send(self.resource, item=item)
def force_delete(self, user): with AuthorizedOperation('delete_resource', 'user', user.id): before_delete.send(user) force_delete_user(user) after_delete.send(user) return None, NO_CONTENT