Ticket #3224: refactor-response-middleware.diff

File refactor-response-middleware.diff, 2.5 KB (added by mihai_preda@…, 18 years ago)

svn diff

  • django/test/client.py

     
    2525        try:
    2626            request = WSGIRequest(environ)
    2727            response = self.get_response(request)
    28 
    29             # Apply response middleware
    30             for middleware_method in self._response_middleware:
    31                 response = middleware_method(request, response)
    32 
    3328        finally:
    3429            dispatcher.send(signal=signals.request_finished)
    3530
  • django/core/handlers/wsgi.py

     
    187187        try:
    188188            request = WSGIRequest(environ)
    189189            response = self.get_response(request)
    190 
    191             # Apply response middleware
    192             for middleware_method in self._response_middleware:
    193                 response = middleware_method(request, response)
    194 
    195190        finally:
    196191            dispatcher.send(signal=signals.request_finished)
    197192
  • django/core/handlers/base.py

     
    4949                self._exception_middleware.insert(0, mw_instance.process_exception)
    5050
    5151    def get_response(self, request):
     52        response = self.get_response_aux(request)
     53       
     54        # Apply response middleware
     55        for middleware_method in self._response_middleware:
     56            response = middleware_method(request, response)
     57        return response
     58
     59    def get_response_aux(self, request):
    5260        "Returns an HttpResponse object for the given HttpRequest"
    5361        from django.core import exceptions, urlresolvers
    5462        from django.core.mail import mail_admins
  • django/core/handlers/modpython.py

     
    148148        try:
    149149            request = ModPythonRequest(req)
    150150            response = self.get_response(request)
    151 
    152             # Apply response middleware
    153             for middleware_method in self._response_middleware:
    154                 response = middleware_method(request, response)
    155 
    156151        finally:
    157152            dispatcher.send(signal=signals.request_finished)
    158153
Back to Top