old_contents: from __future__ import absolute_import
  from __future__ import unicode_literals
  from django.utils.decorators import method_decorator
  from django.utils.deprecation import MiddlewareMixin
  from django.views.decorators.debug import sensitive_post_parameters
  
  from .api import set_request
  
  
  class GlobalRequestMiddleware(MiddlewareMixin):
  
      @method_decorator(sensitive_post_parameters('password'))
      def process_request(self, request):
          set_request(request)
  
      def process_response(self, request, response):
          return response
  
new_contents: from __future__ import absolute_import
  from __future__ import unicode_literals
  from django.utils.decorators import method_decorator
  from django.utils.deprecation import MiddlewareMixin
  from django.views.decorators.debug import sensitive_post_parameters
  
  from .api import set_request
  
  
  class GlobalRequestMiddleware(MiddlewareMixin):
  
      @method_decorator(sensitive_post_parameters('password'))
      def process_request(self, request):
          set_request(request)
  
      def process_response(self, request, response):
          set_request(None)
          return response
  
subject: clear global request when it's over