Skip to content

Commit

Permalink
Merge pull request #304 from zopefoundation/py3_fix_wsgi_unauthorized
Browse files Browse the repository at this point in the history
create exception view before handling Unauthorized
  • Loading branch information
tschorr committed Oct 2, 2018
2 parents 3c56da9 + 2bf75dd commit 1d78cfa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ New features
Bugfixes
++++++++

- Call exception view before triggering _unauthorized.
(`#304 <https://github.com/zopefoundation/Zope/pull/304>`_)

- Fix XML Page template files in Python 3
(`#319 <https://github.com/zopefoundation/Zope/issues/319>`_)

Expand Down
8 changes: 4 additions & 4 deletions src/ZPublisher/WSGIPublisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ def transaction_pubevents(request, response, tm=transaction.manager):
if request.environ.get('x-wsgiorg.throw_errors', False):
reraise(*exc_info)

# Handle exception view
exc_view_created = _exc_view_created_response(
exc, request, response)

if isinstance(exc, Unauthorized):
# _unauthorized modifies the response in-place. If this hook
# is used, an exception view for Unauthorized has to merge
Expand All @@ -157,10 +161,6 @@ def transaction_pubevents(request, response, tm=transaction.manager):
response._unauthorized()
response.setStatus(exc.getStatus())

# Handle exception view
exc_view_created = _exc_view_created_response(
exc, request, response)

notify(pubevents.PubBeforeAbort(
request, exc_info, request.supports_retry()))
tm.abort()
Expand Down

0 comments on commit 1d78cfa

Please sign in to comment.