Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#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)

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

Download all attachments as: .zip

Change History (9)

comment:1 by Malcolm Tredinnick, 16 years ago

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

comment:2 by Jacob, 16 years ago

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 by Jeff Anderson, 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 Brantley, 16 years ago

Attachment: middleware_warnings.patch added

comment:4 by Brantley, 16 years ago

Has patch: set
Owner: changed from nobody to Brantley

comment:5 by Brantley, 16 years ago

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 by Jacob, 16 years ago

Owner: changed from nobody to Jacob
Status: newassigned

comment:7 by Jacob, 16 years ago

Resolution: fixed
Status: assignedclosed

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

comment:8 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

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