Пример #1
0
    def process_response(self, request, response):
        """Commit transaction if it exists, rolling back in an
        exception occurs.
        """

        try:
            if response.status_code >= 400:
                commands.rollback()
            else:
                commands.commit()
        except OperationFailure as err:
            message = utils.get_error_message(err)
            if messages.NO_TRANSACTION_TO_COMMIT_ERROR not in message:
                if settings.DEBUG_TRANSACTIONS:
                    pass
                else:
                    raise err
        except Exception as err:
            try:
                commands.rollback()
            except OperationFailure:
                pass
            else:
                raise err
        commands.disconnect()
        return response
Пример #2
0
    def process_response(self, request, response):
        """Commit transaction if it exists, rolling back in an
        exception occurs.
        """

        try:
            if response.status_code >= 400:
                commands.rollback()
            else:
                commands.commit()
        except OperationFailure as err:
            message = utils.get_error_message(err)
            if messages.NO_TRANSACTION_TO_COMMIT_ERROR not in message:
                if settings.DEBUG_TRANSACTIONS:
                    pass
                else:
                    raise err
        except Exception as err:
            try:
                commands.rollback()
            except OperationFailure:
                pass
            else:
                raise err
        commands.disconnect()
        return response
Пример #3
0
 def process_exception(self, request, exception):
     """If an exception occurs, rollback the current transaction
     if it exists.
     """
     try:
         commands.rollback()
     except OperationFailure as err:
         message = utils.get_error_message(err)
         if messages.NO_TRANSACTION_ERROR not in message:
             raise
     commands.disconnect()
     return None
Пример #4
0
 def process_exception(self, request, exception):
     """If an exception occurs, rollback the current transaction
     if it exists.
     """
     sentry_exception_handler(request=request)
     try:
         commands.rollback()
     except OperationFailure as err:
         message = utils.get_error_message(err)
         if messages.NO_TRANSACTION_ERROR not in message:
             raise
     commands.disconnect()
     return None