Commit 2d53353e authored by Tres Seaver's avatar Tres Seaver

Merge pull request #50 from gweis/master

fix #44 on branch master
parents dc1185bc 07ec7682
...@@ -282,7 +282,7 @@ def publish_module(environ, start_response, ...@@ -282,7 +282,7 @@ def publish_module(environ, start_response,
body = response.body body = response.body
if isinstance(body, file) or IStreamIterator.providedBy(body): if isinstance(body, file) or IUnboundStreamIterator.providedBy(body):
result = body result = body
else: else:
# If somebody used response.write, that data will be in the # If somebody used response.write, that data will be in the
......
...@@ -447,6 +447,31 @@ class Test_publish_module(unittest.TestCase): ...@@ -447,6 +447,31 @@ class Test_publish_module(unittest.TestCase):
app_iter = self._callFUT(environ, start_response, _publish) app_iter = self._callFUT(environ, start_response, _publish)
self.assertTrue(app_iter is body) self.assertTrue(app_iter is body)
def test_response_is_unboundstream(self):
from ZPublisher.Iterators import IUnboundStreamIterator
from zope.interface import implements
class test_unboundstreamiterator:
implements(IUnboundStreamIterator)
data = "hello"
done = 0
def next(self):
if not self.done:
self.done = 1
return self.data
raise StopIteration
_response = DummyResponse()
_response._status = '200 OK'
body = _response.body = test_unboundstreamiterator()
environ = self._makeEnviron()
start_response = DummyCallable()
_publish = DummyCallable()
_publish._result = _response
app_iter = self._callFUT(environ, start_response, _publish)
self.assertTrue(app_iter is body)
def test_request_closed_when_tm_middleware_not_active(self): def test_request_closed_when_tm_middleware_not_active(self):
environ = self._makeEnviron() environ = self._makeEnviron()
start_response = DummyCallable() start_response = DummyCallable()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment