Tuesday, March 27, 2012

Re: Http404 and process_exception

On 28/03/2012, at 6:31 AM, Justin Holmes wrote:

> Heretofore, I had always believed that Http404 did not cause Middleware process_exception() to be run. Am I right in this thinking?
>
> I have a get_object_or_404 that, when the object in question isn't found, is running process_exception.

Http404 is an exception, so yes, it should cause process_exception() to be run.

The test suite for middleware processing might be (slightly) illuminating here; it's a bit long winded and gnarly, but it enumerates and validates the full path for every possible combination of middleware and response type.

Look at regression_tests/middleware_exceptions; test_process_exception_middleware_not_found is the test for your specific case.

Out of interest -- can you put your finger on why you heretofore thought Http404 didn't hit exception middleware? I've done a quick poke through the history of the middleware handling code, and I can't see any obvious reason why this would have changed (even inadvertently).

Yours,
Russ Magee %-)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment