old_contents: from framework.transactions import handlers
  
  class TokuTransactionsMiddleware(object):
      """TokuMX transaction middleware."""
  
      def process_request(self, request):
          handlers.transaction_before_request()
  
      def process_response(self, request, response):
          return handlers.transaction_after_request(response)
  
new_contents: from framework.transactions import handlers, commands
  
  class TokuTransactionsMiddleware(object):
      """TokuMX transaction middleware."""
  
      def process_request(self, request):
          handlers.transaction_before_request()
  
      def process_exception(self, request, exception):
          commands.rollback()
  
      def process_response(self, request, response):
          return handlers.transaction_after_request(response)
  
subject: Make sure transaction is rolled back if an exception is raised