Re: Fixing middleware/view decorator handling of content iterators

2010-02-21 Thread Tai Lee
I didn't think about the author of a `HttpResponse` subclass needing to know all potential middleware that will not work with that particular response class. That is definitely a problem. However, I don't think that exposing a capabilities based API on `HttpResponse` is the answer. If we do that,

Re: Fixing middleware/view decorator handling of content iterators

2010-02-21 Thread Forest Bond
Hi, On Mon, Feb 22, 2010 at 12:39:40AM +, Luke Plant wrote: > On Sunday 21 February 2010 23:07:35 Forest Bond wrote: > > > Simply knowing whether or > > not the response is streaming and whether or not it has a known > > size is sufficient for knowing whether or not you should cache it. >

Re: Fixing middleware/view decorator handling of content iterators

2010-02-21 Thread Luke Plant
On Sunday 21 February 2010 23:07:35 Forest Bond wrote: > Simply knowing whether or > not the response is streaming and whether or not it has a known > size is sufficient for knowing whether or not you should cache it. I can't find it now, but someone definitely had a use case where they defin

Re: Fixing middleware/view decorator handling of content iterators

2010-02-21 Thread Forest Bond
Hi, On Sun, Feb 21, 2010 at 10:44:07PM +0800, Russell Keith-Magee wrote: > To me, it seems like what we need to be able to capture in a response > object is the set of capabilities that a response supports -- For > example: > > * Can I determine the length of this response? > * Can I inspect th

Re: Fixing middleware/view decorator handling of content iterators

2010-02-21 Thread Forest Bond
Hi, On Sun, Feb 21, 2010 at 01:28:23AM -0800, Tai Lee wrote: > On Feb 21, 7:46 am, Forest Bond 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 chec

Re: Fixing middleware/view decorator handling of content iterators

2010-02-21 Thread Russell Keith-Magee
On Sun, Feb 21, 2010 at 5:28 PM, Tai Lee wrote: > On Feb 21, 7:46 am, Forest Bond 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(respon

Re: Fixing middleware/view decorator handling of content iterators

2010-02-21 Thread Russell Keith-Magee
On Sun, Feb 21, 2010 at 5:22 AM, Forest Bond 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 app

Re: Fixing middleware/view decorator handling of content iterators

2010-02-21 Thread Tai Lee
On Feb 21, 7:46 am, Forest Bond 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

Re: Fixing middleware/view decorator handling of content iterators

2010-02-20 Thread Forest Bond
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

Re: Fixing middleware/view decorator handling of content iterators

2010-02-20 Thread Forest Bond
Hi, On Sat, Feb 20, 2010 at 03:46:52PM -0500, Forest Bond wrote: > Then there is the question of how to trigger handling as a streaming response. > Either we require a view to explicitly request it by using a > StreamingHttpResponse instead of a normal HttpResponse, or we assume that if > the > v

Re: Fixing middleware/view decorator handling of content iterators

2010-02-20 Thread Forest Bond
Hi, On Thu, Feb 18, 2010 at 08:40:55PM -0800, Tai Lee wrote: > See also #7581, which has a patch that I have been using in my local > Django branch for over a year without issue. My use case is that I > need to generate large amounts of data in CSV format and stream the > response to avoid timeout

Re: Fixing middleware/view decorator handling of content iterators

2010-02-18 Thread Tai Lee
See also #7581, which has a patch that I have been using in my local Django branch for over a year without issue. My use case is that I need to generate large amounts of data in CSV format and stream the response to avoid timeouts. I wouldn't mind `HttpResponse` consuming `content` immediately if w

Re: [RFC] Fixing middleware/view decorator handling of content iterators

2010-02-18 Thread Forest Bond
Hi, Thanks for your response, Russ. Let me put my use case out there to ground my responses a bit. I'm using Rackspace Cloud Files, a cloud storage service, to store large files (several hundred megabytes up to a few gigabytes in size). I need to serve these files to authenticated users via a v

Re: [RFC] Fixing middleware/view decorator handling of content iterators

2010-02-18 Thread Tom Evans
On Thu, Feb 18, 2010 at 12:00 PM, Russell Keith-Magee wrote: ... > benefit of using an iterator in the first place. So -- I suppose the > bigger question that needs to be asked is what exactly is the use case > for an iterable response? I mean, I understand the general benefit of > using iterators

Re: [RFC] Fixing middleware/view decorator handling of content iterators

2010-02-18 Thread Russell Keith-Magee
On Tue, Feb 16, 2010 at 5:16 AM, Forest Bond wrote: > Hi, > > Django allows an iterator to be passed as response content when instantiating > an > HttpResponse.  However, doing so causes problems with the following classes > and > functions: > > UpdateCacheMiddleware: >  Caches the response obje

Re: [RFC] Fixing middleware/view decorator handling of content iterators

2010-02-15 Thread Forest Bond
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 > wrote: > ... > > * Forbid premature draining of the content iterator via response.content by > > only > >  evaluating the content iterator if accessed via iter(response) and raisin

Re: [RFC] Fixing middleware/view decorator handling of content iterators

2010-02-15 Thread Jeremy Dunck
On Mon, Feb 15, 2010 at 3:16 PM, Forest Bond 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 o

[RFC] Fixing middleware/view decorator handling of content iterators

2010-02-15 Thread Forest Bond
Hi, Django allows an iterator to be passed as response content when instantiating an HttpResponse. However, doing so causes problems with the following classes and functions: UpdateCacheMiddleware: Caches the response object using the configured cache backend, but most iterators cannot be pi