Skip to content

Instantly share code, notes, and snippets.

@meric
Created September 13, 2012 11:26
Show Gist options
  • Save meric/3713696 to your computer and use it in GitHub Desktop.
Save meric/3713696 to your computer and use it in GitHub Desktop.
git diff 2ef7d14040a261fe284a8b72490712d4019a5766__base.py base.py
diff --git a/2ef7d14040a261fe284a8b72490712d4019a5766__base.py b/base.py
index d0a4b63..4c4d9eb 100644
--- a/2ef7d14040a261fe284a8b72490712d4019a5766__base.py
+++ b/base.py
@@ -114,25 +114,23 @@ class BaseHandler(object):
response = middleware_method(request, callback, callback_args, callback_kwargs)
if response:
break
-
- if response is None:
- try:
- response = callback(request, *callback_args, **callback_kwargs)
- except urlresolvers.DoesNotResolve, e:
- # Continue resolve URLs if the view raises
- # urlresolvers.DoesNotResolve exception to indicate
- # the url pattern does not match.
- continue
- except Exception as e:
- # If the view raised an exception, run it through exception
- # middleware, and if the exception middleware returns a
- # response, use that. Otherwise, reraise the exception.
- for middleware_method in self._exception_middleware:
- response = middleware_method(request, e)
- if response:
- break
- if response is None:
- raise
+ try:
+ response = callback(request, *callback_args, **callback_kwargs)
+ except urlresolvers.DoesNotResolve:
+ # Continue resolve URLs if the view raises
+ # urlresolvers.DoesNotResolve exception to indicate
+ # the url pattern does not match.
+ continue
+ except Exception as e:
+ # If the view raised an exception, run it through exception
+ # middleware, and if the exception middleware returns a
+ # response, use that. Otherwise, reraise the exception.
+ for middleware_method in self._exception_middleware:
+ response = middleware_method(request, e)
+ if response:
+ break
+ else:
+ raise
# Complain if the view returned None (a common error).
if response is None:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment