Russell,

Thanks for the reply.

Two reasons:

1) Up until now, I hadn't encountered a 404 that had triggered this
particular process_exception.  It hadn't occurred to me that since
get_object_or_404 actually raises the Http404 exception that the behavior
was going to be different than, say, a try block whose exception clause
returned HttpResponseNotFound.

2) Once I had encountered this phenomenon, a quick google search led me to
this page from the book:

http://www.djangobook.com/en/beta/chapter16/

....which seemed, at least for a moment, to verify my previous experience.

I think though that I simply hadn't raised Http404 since implementing this
middleware.  It makes perfect sense that it behaves the way it does.



On Tue, Mar 27, 2012 at 11:29 PM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

>
> 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+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Justin Holmes

Head Instructor, SlashRoot Collective
SlashRoot: Coffee House and Tech Dojo
60 Main Street
New Paltz, NY 12561
845.633.8330

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to