from . models import HistoricalRecords


class HistoryRequestMiddleware(object):
    """Expose request to HistoricalRecords.

    This middleware sets request as a local thread variable, making it
    available to the model-level utilities to allow tracking of the
    authenticated user making a change.
    """

    def process_request(self, request):
        HistoricalRecords.thread.request = request

    def process_response(self, request, response):
        if hasattr(HistoricalRecords.thread, 'request'):
            del HistoricalRecords.thread.request
        return response

@@ -33,16 +33,162 @@
 ecords%0A%0A
+try:%0A    from django.utils.deprecation import MiddlewareMixin as MiddlewareBase%0Aexcept ImportError:  # Django %3C 1.10%0A    MiddlewareBase = object%0A%0A
 %0Aclass H
@@ -211,22 +211,30 @@
 dleware(
-object
+MiddlewareBase
 ):%0A    %22

Add support for new middleware API