Commit 78e080d6 authored by Jérome Perrin's avatar Jérome Perrin Committed by Arnaud Fontaine

standard_error_message: Adjust exception context for Zope 4

Since Zope 4, the `standard_error_message` is rendered in the context
of REQUEST['PUBLISHED'], which in case of publishing a skin (page
template or script) in the context of a document is is the skin itself,
but for error rendering in case of erp5_web Web Site or Web Section,
we expect standard_error_message_template to always be rendered in the
context of the document, that's why we use REQUEST.PARENTS[0] as context.

REQUEST.PUBLISHED = <PythonScript at /erp5/script used for /erp5/module/document>
REQUEST.PARENTS [<Document>, <Module>, <ERP5Site>, ...]
parent 35137914
...@@ -5,7 +5,10 @@ ...@@ -5,7 +5,10 @@
root is defined then it renders the error from portal. root is defined then it renders the error from portal.
""" """
from zExceptions import Unauthorized from zExceptions import Unauthorized
try: try:
# Adjust exception context for Zope 4.
context = container.REQUEST.get('PARENTS', [context])[0]
return context.standard_error_message_template(*args, **kw) return context.standard_error_message_template(*args, **kw)
except Unauthorized: except Unauthorized:
pass pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment