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
9832090c
Commit
9832090c
authored
Jul 30, 2004
by
Chris Withers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Collector #891: Enabled locking of RESPONSE.setStatus and RESPONSE.setBody
parent
5397bd2b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
doc/CHANGES.txt
doc/CHANGES.txt
+5
-0
lib/python/ZPublisher/HTTPResponse.py
lib/python/ZPublisher/HTTPResponse.py
+13
-2
No files found.
doc/CHANGES.txt
View file @
9832090c
...
@@ -26,6 +26,11 @@ Zope Changes
...
@@ -26,6 +26,11 @@ Zope Changes
Features added
Features added
- RESPONSE.setBody and RESPONSE.setStatus now accept lock
parameters in the same way as RESPONSE.redirect. These prevent
further calls to the methods from overwriting the previous value.
This is useful when writing http proxies.
- DateTime: new DateTime instance can be constructed from a given
- DateTime: new DateTime instance can be constructed from a given
DateTime instance: d_new = DateTime(d_old)
DateTime instance: d_new = DateTime(d_old)
...
...
lib/python/ZPublisher/HTTPResponse.py
View file @
9832090c
...
@@ -146,6 +146,7 @@ class HTTPResponse(BaseResponse):
...
@@ -146,6 +146,7 @@ class HTTPResponse(BaseResponse):
realm
=
'Zope'
realm
=
'Zope'
_error_format
=
'text/html'
_error_format
=
'text/html'
_locked_status
=
0
_locked_status
=
0
_locked_body
=
0
# Indicate if setBody should content-compress output.
# Indicate if setBody should content-compress output.
# 0 - no compression
# 0 - no compression
...
@@ -199,7 +200,7 @@ class HTTPResponse(BaseResponse):
...
@@ -199,7 +200,7 @@ class HTTPResponse(BaseResponse):
"""Returns true if this request requested a server shutdown."""
"""Returns true if this request requested a server shutdown."""
return
self
.
_shutdown_flag
is
not
None
return
self
.
_shutdown_flag
is
not
None
def
setStatus
(
self
,
status
,
reason
=
None
):
def
setStatus
(
self
,
status
,
reason
=
None
,
lock
=
None
):
'''
\
'''
\
Sets the HTTP status code of the response; the argument may
Sets the HTTP status code of the response; the argument may
either be an integer or a string from { OK, Created, Accepted,
either be an integer or a string from { OK, Created, Accepted,
...
@@ -234,6 +235,9 @@ class HTTPResponse(BaseResponse):
...
@@ -234,6 +235,9 @@ class HTTPResponse(BaseResponse):
reason
=
'Unknown'
reason
=
'Unknown'
self
.
setHeader
(
'Status'
,
"%d %s"
%
(
status
,
str
(
reason
)))
self
.
setHeader
(
'Status'
,
"%d %s"
%
(
status
,
str
(
reason
)))
self
.
errmsg
=
reason
self
.
errmsg
=
reason
# lock the status if we're told to
if
lock
:
self
.
_locked_status
=
1
def
setHeader
(
self
,
name
,
value
,
literal
=
0
):
def
setHeader
(
self
,
name
,
value
,
literal
=
0
):
'''
\
'''
\
...
@@ -268,7 +272,8 @@ class HTTPResponse(BaseResponse):
...
@@ -268,7 +272,8 @@ class HTTPResponse(BaseResponse):
latin1_alias_match
=
re
.
compile
(
latin1_alias_match
=
re
.
compile
(
r'text/html(\
s*;
\s*charset=((latin)|(latin[-_]?1)|'
r'text/html(\
s*;
\s*charset=((latin)|(latin[-_]?1)|'
r'(cp1252)|(cp819)|(csISOLatin1)|(IBM819)|(iso-ir-100)|'
r'(cp1252)|(cp819)|(csISOLatin1)|(IBM819)|(iso-ir-100)|'
r'(iso[-_]8859[-_]1(:1987)?)))?$'
,
re
.
I
).
match
r'(iso[-_]8859[-_]1(:1987)?)))?$'
,
re
.
I
).
match
,
lock
=
None
):
):
'''
\
'''
\
Set the body of the response
Set the body of the response
...
@@ -285,6 +290,12 @@ class HTTPResponse(BaseResponse):
...
@@ -285,6 +290,12 @@ class HTTPResponse(BaseResponse):
If is_error is true then the HTML will be formatted as a Zope error
If is_error is true then the HTML will be formatted as a Zope error
message instead of a generic HTML page.
message instead of a generic HTML page.
'''
'''
# allow locking of the body in the same way as the status
if
self
.
_locked_body
:
return
elif
lock
:
self
.
_locked_body
=
1
if
not
body
:
if
not
body
:
return
self
return
self
...
...
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