Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
e1b5bdea
Commit
e1b5bdea
authored
Mar 26, 2011
by
Malthe Borch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport changeset committed to trunk in r121131.
parent
dda24a1c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
3 deletions
+36
-3
doc/CHANGES.rst
doc/CHANGES.rst
+4
-0
src/ZPublisher/WSGIPublisher.py
src/ZPublisher/WSGIPublisher.py
+6
-3
src/ZPublisher/tests/test_WSGIPublisher.py
src/ZPublisher/tests/test_WSGIPublisher.py
+26
-0
No files found.
doc/CHANGES.rst
View file @
e1b5bdea
...
...
@@ -11,6 +11,10 @@ http://docs.zope.org/zope2/releases/.
Bugs Fixed
++++++++++
- Fix `WSGIResponse` and `publish_module` functions such that they
support the `IStreamIterator` interface in addition to `file` (as
supported by `ZServer.HTTPResponse`).
- Corrected copyright information shown in the ZMI.
- OFS: Fixed editing offset-naive 'date' properties in the ZMI.
...
...
src/ZPublisher/WSGIPublisher.py
View file @
e1b5bdea
...
...
@@ -30,6 +30,7 @@ from ZPublisher.Publish import call_object
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 @@ class WSGIResponse(HTTPResponse):
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
)
...
...
@@ -226,8 +227,10 @@ def publish_module(environ, start_response,
status
,
headers
=
response
.
finalize
()
start_response
(
status
,
headers
)
if
isinstance
(
response
.
body
,
file
):
result
=
response
.
body
body
=
response
.
body
if
isinstance
(
body
,
file
)
or
IStreamIterator
.
providedBy
(
body
):
result
=
body
else
:
# If somebody used response.write, that data will be in the
# stdout StringIO, so we put that before the body.
...
...
src/ZPublisher/tests/test_WSGIPublisher.py
View file @
e1b5bdea
...
...
@@ -370,6 +370,32 @@ class Test_publish_module(unittest.TestCase):
app_iter
=
self
.
_callFUT
(
environ
,
start_response
,
_publish
)
self
.
assertTrue
(
app_iter
is
body
)
def
test_response_is_stream
(
self
):
from
ZPublisher.Iterators
import
IStreamIterator
from
zope.interface
import
implements
class
test_streamiterator
:
implements
(
IStreamIterator
)
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'
_response
.
_headers
=
[(
'Content-Length'
,
'4'
)]
body
=
_response
.
body
=
test_streamiterator
()
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
):
environ
=
self
.
_makeEnviron
()
start_response
=
DummyCallable
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment