On Feb 21, 7:46 am, Forest Bond <for...@alittletooquiet.net> wrote:
> Okay, I think "disabled_middleware" is a bad name because it doesn't actually
> imply that all middleware should be disabled.  Anyway, it seems like 
> middleware
> could just check if isinstance(response, StreamingHttpResponse).

I'm not sure I follow your reasoning here. If you just don't like the
name, that's a bike shed argument. I'm proposing that
`disabled_middleware` be a list or tuple of middleware that should NOT
be called on the response, because the author of the `HttpResponse`
subclass that defined `disabled_middleware` knows that those
middleware are not needed or will not work as intended.

The point that I gleaned from earlier discussions is that we cannot
fix this problem in middleware. We cannot have middleware check `if
isinstance(response, StreamingHttpResponse)` and conditionally change
its behaviour because we would force ALL Django and 3rd party
middleware in existence to check for the possibility that a response
has generator or string content and change their behaviour
accordingly.

I believe the answer is to define explicit `HttpResponse` subclasses
and provide a mechanism by which each subclass can explicitly disable
certain middleware. That way, all existing Django and 3rd party
middleware do not need to change or know or care about what kind of
content the response has. Then the developer can simply disable any
middleware that is causing a problem with a particular response,
regardless if it is a problem with streaming, or they don't want an
ETag, or they don't want a response compressed, etc.

Cheers.
Tai.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to