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
f86588ef
Commit
f86588ef
authored
Sep 04, 2016
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small cleanup and add a WSGIRequest subclass.
parent
6199c1e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
22 deletions
+20
-22
src/ZPublisher/WSGIPublisher.py
src/ZPublisher/WSGIPublisher.py
+20
-22
No files found.
src/ZPublisher/WSGIPublisher.py
View file @
f86588ef
...
@@ -124,11 +124,14 @@ def get_module_info(module_name='Zope2'):
...
@@ -124,11 +124,14 @@ def get_module_info(module_name='Zope2'):
return
info
return
info
class
WSGIRequest
(
HTTPRequest
):
"""A request object for WSGI
"""
pass
class
WSGIResponse
(
HTTPResponse
):
class
WSGIResponse
(
HTTPResponse
):
"""A response object for WSGI
"""A response object for WSGI
This Response object knows nothing about ZServer, but tries to be
compatible with the ZServerHTTPResponse.
"""
"""
_streaming
=
0
_streaming
=
0
_http_version
=
None
_http_version
=
None
...
@@ -138,24 +141,19 @@ class WSGIResponse(HTTPResponse):
...
@@ -138,24 +141,19 @@ class WSGIResponse(HTTPResponse):
after_list
=
()
after_list
=
()
def
finalize
(
self
):
def
finalize
(
self
):
# Set 204 (no content) status if 200 and response is empty
headers
=
self
.
headers
# and not streaming.
body
=
self
.
body
if
(
'content-type'
not
in
self
.
headers
and
'content-length'
not
in
self
.
headers
and
# set 204 (no content) status if 200 and response is empty
# and not streaming
if
(
'content-type'
not
in
headers
and
'content-length'
not
in
headers
and
not
self
.
_streaming
and
self
.
status
==
200
):
not
self
.
_streaming
and
self
.
status
==
200
):
self
.
setStatus
(
'nocontent'
)
self
.
setStatus
(
'nocontent'
)
# add content length if not streaming
# Add content length if not streaming.
content_length
=
headers
.
get
(
'content-length'
)
content_length
=
self
.
headers
.
get
(
'content-length'
)
if
content_length
is
None
and
not
self
.
_streaming
:
if
content_length
is
None
and
not
self
.
_streaming
:
self
.
setHeader
(
'content-length'
,
len
(
body
))
self
.
setHeader
(
'content-length'
,
len
(
self
.
body
))
return
'%s %s'
%
(
self
.
status
,
self
.
errmsg
),
self
.
listHeaders
(
)
return
(
'%s %s'
%
(
self
.
status
,
self
.
errmsg
),
self
.
listHeaders
()
)
def
listHeaders
(
self
):
def
listHeaders
(
self
):
result
=
[]
result
=
[]
...
@@ -168,16 +166,16 @@ class WSGIResponse(HTTPResponse):
...
@@ -168,16 +166,16 @@ class WSGIResponse(HTTPResponse):
def
_unauthorized
(
self
):
def
_unauthorized
(
self
):
self
.
setStatus
(
401
)
self
.
setStatus
(
401
)
realm
=
self
.
realm
if
self
.
realm
:
if
realm
:
self
.
setHeader
(
'WWW-Authenticate'
,
self
.
setHeader
(
'WWW-Authenticate'
,
'basic realm="%s"'
%
realm
,
1
)
'basic realm="%s"'
%
self
.
realm
,
1
)
def
write
(
self
,
data
):
def
write
(
self
,
data
):
"""
Add data to our output stream.
"""Add data to our output stream.
HTML data may be returned using a stream-oriented interface.
HTML data may be returned using a stream-oriented interface.
This allows the browser to display partial results while
This allows the browser to display partial results while
computation of a response
to proceed
.
computation of a response
proceeds
.
"""
"""
if
not
self
.
_streaming
:
if
not
self
.
_streaming
:
notify
(
pubevents
.
PubBeforeStreaming
(
self
))
notify
(
pubevents
.
PubBeforeStreaming
(
self
))
...
@@ -295,7 +293,7 @@ def publish_module(environ, start_response,
...
@@ -295,7 +293,7 @@ def publish_module(environ, start_response,
_response
=
None
,
_response
=
None
,
_response_factory
=
WSGIResponse
,
_response_factory
=
WSGIResponse
,
_request
=
None
,
_request
=
None
,
_request_factory
=
HTTP
Request
,
_request_factory
=
WSGI
Request
,
_module_name
=
'Zope2'
,
_module_name
=
'Zope2'
,
):
):
module_info
=
get_module_info
(
_module_name
)
module_info
=
get_module_info
(
_module_name
)
...
...
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