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
4d31853c
Commit
4d31853c
authored
Apr 21, 2010
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- fixed handling of exceptions with unicode values
parent
aa6b8b78
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
1 deletion
+28
-1
doc/CHANGES.rst
doc/CHANGES.rst
+2
-0
src/ZPublisher/HTTPResponse.py
src/ZPublisher/HTTPResponse.py
+4
-1
src/ZPublisher/tests/exception_handling.txt
src/ZPublisher/tests/exception_handling.txt
+22
-0
No files found.
doc/CHANGES.rst
View file @
4d31853c
...
...
@@ -55,6 +55,8 @@ Features Added
Bugs Fixed
++++++++++
- HTTPResponse: Fixed handling of exceptions with unicode values.
- zExceptions: Fixed some unicode issues in Unauthorized.
- LP #372632, comments #15ff.: Fixed regression in Unauthorized handling.
...
...
src/ZPublisher/HTTPResponse.py
View file @
4d31853c
...
...
@@ -800,7 +800,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 @
4d31853c
...
...
@@ -140,6 +140,28 @@ Handle zExceptions.Unauthorized raised by the object. We take the
...
Unauthorized: ERROR VALUE
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>
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