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
69389d5c
Commit
69389d5c
authored
Apr 21, 2010
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- fixed handling of exceptions with unicode values
parent
d7d17593
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
src/ZPublisher/HTTPResponse.py
src/ZPublisher/HTTPResponse.py
+4
-1
src/ZPublisher/tests/exception_handling.txt
src/ZPublisher/tests/exception_handling.txt
+23
-0
No files found.
src/ZPublisher/HTTPResponse.py
View file @
69389d5c
...
...
@@ -795,7 +795,10 @@ class HTTPResponse(BaseResponse):
b = v
if isinstance(b, Exception):
try:
b = str(b)
try:
b = str(b)
except UnicodeEncodeError:
b = self._encode_unicode(unicode(b))
except:
b = '
<
unprintable
%
s
object
>
' % type(b).__name__
...
...
src/ZPublisher/tests/exception_handling.txt
View file @
69389d5c
...
...
@@ -147,6 +147,29 @@ Handle zExceptions.Unauthorized raised by the object. We take the
Unauthorized: ERROR VALUE
>>> browser.contents
And the same with unicode error value.
>>> app.test_folder_1_.foo.exception = Unauthorized(u'ERROR VALUE \u03A9')
>>> browser.handleErrors = True
>>> browser.open('http://localhost/test_folder_1_/foo')
Traceback (most recent call last):
...
HTTPError: HTTP Error 401: Unauthorized
>>> 'Error Type: Unauthorized' in browser.contents
True
>>> 'Error Value: ERROR VALUE ?' in browser.contents
True
>>> browser.headers['WWW-Authenticate']
'basic realm="Zope2"'
>>> browser.handleErrors = False
>>> browser.open('http://localhost/test_folder_1_/foo')
Traceback (most recent call last):
...
Unauthorized: <unprintable ... object>
>>> browser.contents
Handle zExceptions.Unauthorized raised by BaseRequest.traverse. We take the
'WWW-Authenticate' header as a sign that HTTPResponse._unauthorized was called.
...
...
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