Re: PdataStreamIterator bug?
Roché Compaan <roche-kb4xc5yObU3kQYj/0HfcvhBnub05S5/[email protected]> Thu, 25 May 2006 17:27:55 +0200
| Newsgroups | gmane.comp.web.zope.plone.archetypes.devel |
|---|---|
| Organization | Upfront Systems |
| Message-ID | <[email protected]> |
On Thu, 2006-05-25 at 11:17 -0300, Sidnei da Silva wrote:
> On Thu, May 25, 2006 at 04:10:49PM +0200, Roché Compaan wrote:
> | I can't see how it can make any difference. What does it matter where
> | you stream the file from? At the moment you're streaming it from a
> | tempfile, how can streaming it from a chain of Pdata objects break
> | ExternalEditor?
>
> You're not getting it. :)
Maybe :-)
> Streaming directly using RESPONSE.write() breaks ExternalEditor.
I'm not saying one should use RESPONSE.write, I'm saying it is not
necessary to write to tempfile first. Basically I'm suggesting a
slightly different implementation of PdataStreamIterator.next(). This
works with ExternalEditor btw.:
class PdataStreamIterator(object):
__implements__ = (IStreamIterator,)
def __init__(self, data, size):
self.data = data
self.size = size
def __iter__(self):
return self
def next(self):
if self.data is None:
raise StopIteration
data = self.data
self.data = data.next
return data.data
def __len__(self):
return self.size
> Returning a stream iterator and letting ZPublisher do the streaming
> works with ExternalEditor. This is what I'm doing.
The above code does too.
> It needs to be read completely before the next() method gets called
> at the point next() gets called the ZODB connection might have been
> closed already.
Again, I don't see what the difference is between reading from Pdata or
from a tempfile. The ZODB connection can be closed while reading from a
tempfile too.
--
Roché Compaan
Upfront Systems http://www.upfrontsystems.co.za
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid7521&bid$8729&dat1642