On Sun, Feb 21, 2010 at 5:22 AM, Forest Bond <for...@alittletooquiet.net> wrote:
> Hi,
>
> Sorry for the volume of messages, but I had one more note to add. ;)
>
> On Sat, Feb 20, 2010 at 03:46:52PM -0500, Forest Bond wrote:
>> Here are the use cases that have been identified:
>>
>> 1. A content iterator was passed for no apparent reason.  The view could just
>>    as easily have returned HttpResponse(''.join(iterator)) with no ill 
>> effects.
>>    I assume this use-case is what people have in mind when they talk about
>>    evaluating the iterator and storing the content in memory or on disk; 
>> doing
>>    this with large responses could cause a connection timeout.
>
> If it wasn't already clear, I don't think that this use case is one that 
> should
> be supported.  I included it because it seems that there is some expectation
> that it is (as evidenced by the proposal that iterators be evaluated and the
> result stored in memory or on disk).

I agree in spirit, but I'm not sure I can agree in practice. The docs
currently say it's ok to return an iterator in a response. As this
discussion and the various tickets indicate, this isn't entirely true.
However, in order to be backwards compatible with our documented API,
you *should* be able to use an iterator in a normal HTTPResponse.

That doesn't mean it has to be spectacularly efficient -- we could
simply baking an iterator with ''.join(iterator) if it is provided to
HttpResponse. However, it would mean that any existing uses of
iterators would continue to work, and the iterator draining bugs would
disappear.

As a way out of this documentation hole, part of the solution may be
to deprecate the use of iterators in HttpResponse (in favor of
StreamingHttpResponse, or whatever we end up with). If the
''.join(iterator) call also raises a PendingDeprecation warning, we
can drive people to either fix their code (manually evaluating the
iterator before using it), or switch to the streaming response type.

Yours,
Russ Magee %-)

-- 
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