Hi, On Mon, Feb 15, 2010 at 03:27:27PM -0600, Jeremy Dunck wrote: > On Mon, Feb 15, 2010 at 3:16 PM, Forest Bond <for...@alittletooquiet.net> > wrote: > ... > > * Forbid premature draining of the content iterator via response.content by > > only > > evaluating the content iterator if accessed via iter(response) and raising > > an > > exception if it is accessed via response.content. > ... > > * Is this type of change too invasive for 1.2? > > I assume you mean 1.3, since 1.2 is in feature freeze.
... and so this change would be disallowed if considered a new feature, but it's purpose is to fix bugs, although it is a non-trivial change. > Anyway, the response.content attribute is documented and client code > may depend on it, making this a backwards-compatibility issue. > > http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpResponse.content Yes, I did address this in my message. Accessing response.content if an iterator was passed in would result in an empty response, which doesn't seem like behavior that is worth preserving in the name of backwards compatibility. On the other hand, the following pattern is the exception (this would not produce an empty response): response.content = some_function(response.content) I think that pattern is the primary backwards compatibility concern. > For GZip support of iterators and similar large in-flight values, I > think spooling to memory and disk, like file upload does, might be a > reasonable solution, but still, .content is just a string, so it'll be > difficult to keep compatibility. If backwards compatibility for this case must be maintained, my approach would need to be adjusted to either evaluate the iterator and store the result (as you suggest) or to keep the current behavior WRT response.content and just fix the offending middleware/view decorators (i.e. use my patch but not throw an exception when response.content is read). If we do take the evaluate-and-store approach, I'd want to give the user some control over this behavior so that he could disable it if the content was going to be quite large or otherwise inappropriate for temporary storage. Thanks for your feedback! -Forest -- Forest Bond http://www.alittletooquiet.net http://www.pytagsfs.org
signature.asc
Description: Digital signature