#8538 closed (fixed)
Document when process_response and process_exception middleware is invoked
Reported by: | TP | Owned by: | Jacob |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | middleware | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
It would be helpful if the django docs better covered the exact semantics of when middleware handlers are invoked. For example, if there's an exception will my custom middleware's process_exception hander be called? How about my process_response handler? This caused some subtle bugs on our website and I thought the docs could go into this more to help other people.
It turns out that django runs exception handlers specified in middleware until one of them returns a response or until django has executed every exception handler. This means your custom handler may or may not be invoked. Second, if some exception handler returns a HttpResponse then the response handlers will be invoked. So your custom process_response may or may not be called after an exception occurs.
Attachments (1)
Change History (9)
comment:1 by , 16 years ago
Summary: | when process_response and process_exception middleware is invoked → Document when process_response and process_exception middleware is invoked |
---|
comment:2 by , 16 years ago
milestone: | → 1.1 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 16 years ago
I'm willing to write a patch for this. Is it appropriate to take the graphic from the Django book verbatim and include it here?
by , 16 years ago
Attachment: | middleware_warnings.patch added |
---|
comment:4 by , 16 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
comment:5 by , 16 years ago
Owner: | changed from | to
---|
Ah, sorry hadn't updated and just did this. Go ahead programmerq, if you want to take from the book.
comment:6 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:7 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
This has been fixed for a bit; not exactly sure when it got checked in.
There's a graphic in ch 3 of the django book that explains this; we should adapt it into the middleware docs for clarity.