[Zope-dev] SVN: Zope/trunk/ Adding support for ``IStreamIterator`` to WSGI publishing machinery.
Laurence Rowe
l at lrowe.co.uk
Mon Mar 28 06:43:06 EDT 2011
On 26 March 2011 17:14, Tres Seaver <tseaver at palladion.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 03/26/2011 12:53 PM, Malthe Borch wrote:
>> Log message for revision 121131:
>> Adding support for ``IStreamIterator`` to WSGI publishing machinery.
>>
>> Changed:
>> U Zope/trunk/doc/CHANGES.rst
>> U Zope/trunk/src/ZPublisher/WSGIPublisher.py
>> U Zope/trunk/src/ZPublisher/tests/test_WSGIPublisher.py
>>
>> -=-
>> Modified: Zope/trunk/doc/CHANGES.rst
>> ===================================================================
>> --- Zope/trunk/doc/CHANGES.rst 2011-03-25 17:39:14 UTC (rev 121130)
>> +++ Zope/trunk/doc/CHANGES.rst 2011-03-26 16:53:52 UTC (rev 121131)
>> @@ -11,6 +11,10 @@
>> Bugs Fixed
>> ++++++++++
>>
>> +- Fix `WSGIResponse` and `publish_module` functions such that they
>> + support the `IStreamIterator` interface in addition to `file` (as
>> + supported by `ZServer.HTTPResponse`).
>> +
>> - Made sure getConfiguration().default_zpublisher_encoding is set correctly.
>>
>> - LP #713253: Prevent publication of acquired attributes, where the acquired
>>
>> Modified: Zope/trunk/src/ZPublisher/WSGIPublisher.py
>> ===================================================================
>> --- Zope/trunk/src/ZPublisher/WSGIPublisher.py 2011-03-25 17:39:14 UTC (rev 121130)
>> +++ Zope/trunk/src/ZPublisher/WSGIPublisher.py 2011-03-26 16:53:52 UTC (rev 121131)
>> @@ -30,6 +30,7 @@
>> from ZPublisher.Publish import dont_publish_class
>> from ZPublisher.Publish import get_module_info
>> from ZPublisher.Publish import missing_name
>> +from ZPublisher.Iterators import IStreamIterator
>>
>> _NOW = None # overwrite for testing
>> def _now():
>> @@ -125,7 +126,7 @@
>> self.stdout.write(data)
>>
>> def setBody(self, body, title='', is_error=0):
>> - if isinstance(body, file):
>> + if isinstance(body, file) or IStreamIterator.providedBy(body):
>> body.seek(0, 2)
>> length = body.tell()
>> body.seek(0)
>
> This part of the patch can't possibly work in the general case: nothing
> in IStreamIterator promises that 'seek' and 'tell' are available.
In plone.subrequest, I need similar functionality. I ended up checking
for seek before calling it and special casing a plone.app.blob
iterator. http://dev.plone.org/plone/browser/plone.subrequest/trunk/plone/subrequest/subresponse.py
Perhaps we want an extended sub-interface for IFileStreamIterator
which defines seek(), tell() and read()?
Laurence
More information about the Zope-Dev
mailing list