Commits

Anonymous committed f1c6269

0.91-bugfixes: Move request middleware into the handler's try/catch block so we can deal with exceptions it throws

Comments (0)

Files changed (1)

django/core/handlers/base.py

         # Reset query list per request.
         db.db.queries = []
 
-        # Apply request middleware
-        for middleware_method in self._request_middleware:
-            response = middleware_method(request)
-            if response:
-                return response
-
         resolver = urlresolvers.RegexURLResolver(r'^/', ROOT_URLCONF)
         try:
+            # Apply request middleware
+            for middleware_method in self._request_middleware:
+                response = middleware_method(request)
+                if response:
+                    return response
+            
             callback, callback_args, callback_kwargs = resolver.resolve(path)
 
             # Apply view middleware