On Fri, Aug 14, 2009 at 3:13 AM, ccahoon<chris.cah...@gmail.com> wrote:
> One bit of advice I am looking for is what people's opinions are on
> the use of isinstance versus hasattr to determine functionality. I am
> personally partial to hasattr, because it covers subclasses, but I do
> not know what the community tends to go towards. Right now, in
> core.handlers.base on my branch, I am using both to deal with
> selective application of response middleware, but I would like to
> choose one or the other.

One thing I'm curious about here is the HTTP Content-Length header.
It's late and I'm tired and cranky, so I may have missed it, but
outside of the infrastructure for runserver I can't find any place
where Django reliably sets it on outgoing responses. And the WSGI
spec's stance is that if the client supports it, a missing
Content-Length can be taken as a cue to chunk the response
(unfortunately WSGI forbids the one HTTP header that truly serves as a
reliable source of information for this).

If we could get some sort of mechanism for having HttpResponse set the
Content-Length header (or not) as needed, we'd have something which
would be a lot more consistent, and not just at the Django level.
Middlewares which want to look at the response body could check for
the header: if it's there the response is safe to
inspect/consume/fiddle with, and if it's missing the response is not
safe to inspect/consume/fiddle with. Servers would still be free to do
what they like, and presumably people who want to stream out a
response piece by piece will use servers which implement the behavior
permitted by WSGI. This sidesteps your question about type checking,
and uses a mechanism which is at least semi-blessed by the gateway
protocol, so it has interoperability benefits beyond Django middleware
classes.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@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