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
a8b516e4
Commit
a8b516e4
authored
Jun 22, 2010
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- small refactoring for better readability: moved some code in separate _setBCIHeaders method
parent
2d0f0209
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
19 deletions
+35
-19
src/ZPublisher/HTTPResponse.py
src/ZPublisher/HTTPResponse.py
+18
-19
src/ZPublisher/tests/testHTTPResponse.py
src/ZPublisher/tests/testHTTPResponse.py
+17
-0
No files found.
src/ZPublisher/HTTPResponse.py
View file @
a8b516e4
...
@@ -755,21 +755,7 @@ class HTTPResponse(BaseResponse):
...
@@ -755,21 +755,7 @@ class HTTPResponse(BaseResponse):
m
=
m
+
'<p>
\
n
No Authorization header found.</p>'
m
=
m
+
'<p>
\
n
No Authorization header found.</p>'
raise
Unauthorized
,
m
raise
Unauthorized
,
m
def
exception
(
self
,
fatal
=
0
,
info
=
None
,
def
_setBCIHeaders
(
self
,
t
,
tb
):
absuri_match
=
re
.
compile
(
r'\
w+://[
\w\
.]+
').match,
tag_search=re.compile('
[
a
-
zA
-
Z
]
>
').search,
abort=1
):
if isinstance(info, tuple) and len(info) == 3:
t, v, tb = info
else:
t, v, tb = sys.exc_info()
if issubclass(t, Unauthorized):
self._unauthorized()
stb = tb # note alias between tb and stb
try
:
try
:
# Try to capture exception info for bci calls
# Try to capture exception info for bci calls
et
=
translate
(
str
(
t
),
nl2sp
)
et
=
translate
(
str
(
t
),
nl2sp
)
...
@@ -794,13 +780,26 @@ class HTTPResponse(BaseResponse):
...
@@ -794,13 +780,26 @@ class HTTPResponse(BaseResponse):
self
.
setHeader
(
'bobo-exception-file'
,
ef
)
self
.
setHeader
(
'bobo-exception-file'
,
ef
)
self
.
setHeader
(
'bobo-exception-line'
,
el
)
self
.
setHeader
(
'bobo-exception-line'
,
el
)
except
:
except
:
# Dont try so hard that we cause other problems ;)
# Don
'
t try so hard that we cause other problems ;)
pass
pass
tb = stb # original traceback
del
tb
del stb
def
exception
(
self
,
fatal
=
0
,
info
=
None
,
absuri_match
=
re
.
compile
(
r'\
w+://[
\w\
.]+
').match,
tag_search=re.compile('
[
a
-
zA
-
Z
]
>
').search,
abort=1
):
if isinstance(info, tuple) and len(info) == 3:
t, v, tb = info
else:
t, v, tb = sys.exc_info()
if issubclass(t, Unauthorized):
self._unauthorized()
self._setBCIHeaders(t, tb)
self.setStatus(t)
self.setStatus(t)
if self.status >= 300 and self.status < 400:
if self.status >= 300 and self.status < 400:
if isinstance(v, str) and absuri_match(v) is not None:
if isinstance(v, str) and absuri_match(v) is not None:
...
...
src/ZPublisher/tests/testHTTPResponse.py
View file @
a8b516e4
...
@@ -1280,6 +1280,23 @@ class HTTPResponseTests(unittest.TestCase):
...
@@ -1280,6 +1280,23 @@ class HTTPResponseTests(unittest.TestCase):
self
.
assertEqual
(
len
(
lines
),
1
)
self
.
assertEqual
(
len
(
lines
),
1
)
self
.
assertEqual
(
lines
[
0
],
'Kilroy was here!'
)
self
.
assertEqual
(
lines
[
0
],
'Kilroy was here!'
)
def
test__setBCIHeaders
(
self
):
response
=
self
.
_makeOne
()
try
:
raise
AttributeError
(
'ERROR VALUE'
)
except
AttributeError
:
t
,
v
,
tb
=
sys
.
exc_info
()
response
.
_setBCIHeaders
(
t
,
tb
)
# required by Bobo Call Interface (BCI)
self
.
assertEqual
(
response
.
headers
[
'bobo-exception-type'
],
"<type 'exceptions.AttributeError'>"
)
self
.
assertEqual
(
response
.
headers
[
'bobo-exception-value'
],
'See the server error log for details'
)
self
.
failUnless
(
'bobo-exception-file'
in
response
.
headers
)
self
.
failUnless
(
'bobo-exception-line'
in
response
.
headers
)
finally
:
del
tb
def
test_exception_Internal_Server_Error
(
self
):
def
test_exception_Internal_Server_Error
(
self
):
response
=
self
.
_makeOne
()
response
=
self
.
_makeOne
()
try
:
try
:
...
...
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