On Aug 19, 9:35 pm, Paul McMillan <[email protected]> wrote:
> I replied on the ticket, but for the record here as well, the issue of
> consuming the iterator multiple times is tracked in #7581. I don't
> think that issue needs to be a blocker for this one, since it has
> existed for quite some time now.
>
> https://code.djangoproject.com/ticket/7581

By the way, it would be really good to fix that issue. The quantum
state of response.content (you change it by measuring it) is a bit
surprising to say the least. For example, try this in IPython:

>>> r = HttpResponse(iter(['a', 'b']))
>>> r.content
''
>>> r2 = HttpResponse(iter(['a', 'b']))
>>> print r2.content
'ab'
>>> r3 = HttpResponse(iter(['a', 'b']))
>>> r3.content == r3.content
False

That might be breaking some Python conventions.

Currently, a third party Middleware writer has zero chance to get the
logic right on first try if he doesn't know about this gotcha. If he
needs the content of a response, he will supposedly use the
response.content attribute. And not test what happens when the content
is an iterator. There is no mention of this issue in "writing your own
middleware" section of Django documentation.

 - Anssi

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

Reply via email to