Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
Directly call zope.globalrequest, as the ZCML hooks are gone.
Browse files Browse the repository at this point in the history
Also remove ill-conceived special handling of HTTPOk/HTTPRedirection.
  • Loading branch information
hannosch authored and Michael Howitz committed Sep 15, 2017
1 parent f2cd9ca commit 0c5c08d
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions src/ZServer/ZPublisher/Publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from six import reraise
from zExceptions import (
HTTPOk,
HTTPRedirection,
Redirect,
)
from zExceptions import Redirect
from zope.event import notify
from zope.globalrequest import setRequest, clearRequest
from zope.publisher.interfaces import ISkinnable
from zope.publisher.interfaces.browser import IBrowserPage
from zope.publisher.skinnable import setDefaultSkin
Expand Down Expand Up @@ -140,18 +137,13 @@ def publish(request, module_name, after_list, debug=0,
if transactions_manager:
recordMetaData(object, request)

ok_exception = None
try:
result = mapply(object, request.args, request,
call_object, 1,
missing_name,
dont_publish_class,
request, bind=1)
except (HTTPOk, HTTPRedirection) as exc:
ok_exception = exc
else:
if result is not response:
response.setBody(result)
result = mapply(object, request.args, request,
call_object, 1,
missing_name,
dont_publish_class,
request, bind=1)
if result is not response:
response.setBody(result)

notify(pubevents.PubBeforeCommit(request))

Expand All @@ -161,9 +153,6 @@ def publish(request, module_name, after_list, debug=0,
notify(pubevents.PubSuccess(request))
endInteraction()

if ok_exception:
raise ok_exception

return response
except:
# save in order to give 'PubFailure' the original exception info
Expand Down Expand Up @@ -261,6 +250,8 @@ def publish_module_standard(
if request is None:
request = Request(stdin, environ, response)

setRequest(request)

# make sure that the request we hand over has the
# default layer/skin set on it; subsequent code that
# wants to look up views will likely depend on it
Expand Down Expand Up @@ -298,6 +289,7 @@ def publish_module_standard(
finally:
if request is not None:
request.close()
clearRequest()

if must_die:
# Try to turn exception value into an exit code.
Expand Down

0 comments on commit 0c5c08d

Please sign in to comment.