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)

@@ -36,16 +36,26 @@
 handlers
+, commands
 %0A%0Aclass 
@@ -219,16 +219,98 @@
 uest()%0A%0A
+    def process_exception(self, request, exception):%0A        commands.rollback()%0A%0A
     def 

Make sure transaction is rolled back if an exception is raised