Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#8538 closed (fixed)

Document when process_response and process_exception middleware is invoked

Reported by: TP Owned by: Jacob
Component: Documentation Version: master
Severity: Keywords: middleware
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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)

middleware_warnings.patch (1.3 KB) - added by Brantley 8 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 8 years ago by Malcolm Tredinnick

Summary: when process_response and process_exception middleware is invokedDocument when process_response and process_exception middleware is invoked

comment:2 Changed 8 years ago by Jacob

milestone: 1.1
Triage Stage: UnreviewedAccepted

There's a graphic in ch 3 of the django book that explains this; we should adapt it into the middleware docs for clarity.

comment:3 Changed 8 years ago by Jeff Anderson

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?

Changed 8 years ago by Brantley

Attachment: middleware_warnings.patch added

comment:4 Changed 8 years ago by Brantley

Has patch: set
Owner: changed from nobody to Brantley

comment:5 Changed 8 years ago by Brantley

Owner: changed from Brantley to nobody

Ah, sorry hadn't updated and just did this. Go ahead programmerq, if you want to take from the book.

comment:6 Changed 8 years ago by Jacob

Owner: changed from nobody to Jacob
Status: newassigned

comment:7 Changed 8 years ago by Jacob

Resolution: fixed
Status: assignedclosed

This has been fixed for a bit; not exactly sure when it got checked in.

comment:8 Changed 5 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top