Django

Code

Ticket #11322 (closed: fixed)

Opened 9 months ago

Last modified 9 months ago

Description of process_response Middleware method incorrect

Reported by: mmalone Assigned to: nobody
Milestone: Component: Documentation
Version: SVN Keywords: middleware documentation response
Cc: mjmalone@gmail.com Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

The Middleware documentation says that if some middleware returns an HttpResponse object from its process_response() method, other middleware that follows it in the chain will not be executed. While this is true for the process_request() and process_view() methods, it is not true for process_response() (see relevant code for how request, view, and response middleware is handled). In fact, the process_response() method must return an HttpResponse object, as its return value is used as the response object passed to any other middleware, and eventually rendered as an HTTP response.

I also think it's worth noting in the description of process_response() that, if present, this method will always be called for every response, even if request middleware that precedes it in the middleware stack short circuits and returns an HttpResponse.

Since both of these appear to be intentional design decisions I've attached a small documentation patch that addresses both issues.

Attachments

middleware_docs.diff (1.6 kB) - added by mmalone on 06/15/09 18:04:24.

Change History

06/15/09 18:04:24 changed by mmalone

  • attachment middleware_docs.diff added.

06/15/09 18:07:51 changed by Alex

  • needs_better_patch changed.
  • stage changed from Unreviewed to Ready for checkin.
  • needs_tests changed.
  • needs_docs changed.

06/18/09 08:34:27 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.

(In [11048]) Fixed #11322 -- Clarified docs regarding middleware processing. Thanks the Michael Malone for the patch.

06/18/09 09:16:14 changed by russellm

(In [11060]) [1.0.X] Fixed #11322 -- Clarified docs regarding middleware processing. Thanks the Michael Malone for the patch.

Merge of r11048 from trunk.


Add/Change #11322 (Description of process_response Middleware method incorrect)




Change Properties
Action