>Also, can you come up with an actual middleware, which needs
>to run in different places in the req. and resp. chains? Otherwise
>this whole discussion is a bit academic, and the code to handle
>it in django would be cruft.

As I wrote in the ticket #730: the LocaleMiddleware needs to come in
process_request _after_ the SessionMiddleware, because it needs the
session handling (the language discovery is done in the
process_request). But it modifies the Vary header, so it must come
_after_ the CacheMiddleware to come _before_ it in the
process_response. So it must be:

CacheMiddleware
SessionMiddleware
LocaleMiddleware

to make sure that the CacheMiddleware is run last on process_response
(for caching), first on process_request (for shortcutting) and both
session and translation are initialized int the right order.

Alone this description should be pointer enough that we really need
more obvious ways to order middlewares for process_response than just
"reverse the list of middlewares". It shouldn't take two paragraphs and
one explicit list to tell people how to order middleware with respect
to process_request and process_response ;-)

I think the reversed order is just counter-intuitive - you just don't
think about it when adding middleware and talking about middleware. So
I think at least an optional way to explicitely specify the order would
be nice.

bye, Georg

Reply via email to