Skip to content

Commit

Permalink
Return to not raising an exception when response.redirect() is called
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli authored and thet committed Apr 3, 2017
1 parent 513677e commit df96774
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Expand Up @@ -29,6 +29,12 @@ Bugs Fixed
- Use unicode transaction-notes to support ZODB 5.
[pbauer]

- Don't raise an exception when `WSGIResponse.redirect` is called
(these redirects should be followed even when the test browser uses
`handleErrors = False`).
[davisagli]


Features Added
++++++++++++++

Expand Down
12 changes: 6 additions & 6 deletions src/ZPublisher/HTTPResponse.py
Expand Up @@ -1010,13 +1010,13 @@ def unauthorized(self):
raise exc

def redirect(self, location, status=302, lock=0):
"""Cause a redirection."""
"""Cause a redirection without raising an error"""
if isinstance(location, HTTPRedirection):
raise location

exc = Redirect(str(location))
exc.setStatus(status)
raise exc
status = location.getStatus()
location = str(location)
self.setStatus(status, lock=lock)
self.setHeader('Location', location)
return location

def exception(self, fatal=0, info=None, abort=1):
if isinstance(info, tuple) and len(info) == 3:
Expand Down
1 change: 1 addition & 0 deletions src/ZPublisher/tests/test_pubevents.py
Expand Up @@ -180,6 +180,7 @@ class _Request(BaseRequest):
response = WSGIResponse()
_hacked_path = False
args = ()
environ = {}

def __init__(self, *args, **kw):
BaseRequest.__init__(self, *args, **kw)
Expand Down

0 comments on commit df96774

Please sign in to comment.