def handle_delete(self, action, data): count = self.delete_subobjects() container = self.context.__parent__ trusted = removeSecurityProxy(self.context) session = Session() session.delete(trusted) count += 1 try: session.flush() except IntegrityError, e: # this should not happen in production; it's a critical # error, because the transaction might have failed in the # second phase of the commit session.rollback() log.critical(e) self.status = _( "Could not delete item due to database integrity error. " "You may wish to try deleting any related sub-records first?") return self.render()