[Zope-dev] Streaming Response

Dieter Maurer dieter@handshake.de
Wed, 16 Apr 2003 21:02:11 +0200


Casey Duncan wrote at 2003-4-16 11:56 -0400:
 > ...
 > Here is the code in question from the index_html method of OFS/Image.py:
 > 
 >         data=self.data
 >         if type(data) is type(''): 
 >             RESPONSE.setBase(None)
 >             return data
 > 
 >         while data is not None:
 >             RESPONSE.write(data.data)
 >             data=data.next
 > 
 >         return ''
 > 
 > Although a reference to data is not kept here, I imagine the ZODB cache may 
 > keep a reference. Perhaps this should be changed to explicitly discard it 
 > from the cache each time through the loop?
 > 
 > If the whole thing is indeed loaded into memory, then it pretty much defeats 
 > the purpose of this code.

I agree.

Change it to:

       while data is not None:
	     RESPONSE.write(data.data)
	     ndata= data.next
	     data._p_deactivate()
	     data= ndata


Dieter