On 29/03/2012, at 12:10 AM, Justin Holmes wrote: > 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.
Yes - that does seem to suggest 404's don't trigger exception middleware. However, I've checked the code back to the magic-removal merge (in 2005) [1], and I can't see any evidence that 404's have ever been a special case. [1] https://code.djangoproject.com/browser/django/trunk/django/core/handlers/base.py?rev=2809#L73 The only change to this area that I can see is to make sure that the response raised by the exception middleware is in recent times has been a modification that means that if the exception middleware returns a response, that response goes through the response middleware; back in the days of magic-removal, it would be returned verbatim. > 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. Yes and no; yes, in that it's an exception; no, in that it's an interesting inconsistency that 404s are (or can be) handled as exceptions, but no other status code is handled as an exception. 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.