From a2e26150b77cd2cdad4cc9de120a87a6370c6dd5 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sat, 15 Oct 2005 02:20:35 +0000 Subject: Fixed #616 -- Added a process_exception() hook to middleware framework. Thanks, Hugo git-svn-id: http://code.djangoproject.com/svn/django/trunk@880 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/utils/decorators.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'django/utils') diff --git a/django/utils/decorators.py b/django/utils/decorators.py index 1333f9da88..074532e741 100644 --- a/django/utils/decorators.py +++ b/django/utils/decorators.py @@ -16,7 +16,14 @@ def decorator_from_middleware(middleware_class): result = middleware.process_view(request, view_func, **kwargs) if result is not None: return result - response = view_func(request, *args, **kwargs) + try: + response = view_func(request, *args, **kwargs) + except Exception, e: + if hasattr(middleware, 'process_exception'): + result = middleware.process_exception(request, e) + if result is not None: + return result + raise e if hasattr(middleware, 'process_response'): result = middleware.process_response(request, response) if result is not None: -- cgit v1.3