Commit cbda4d83 authored by Aurel's avatar Aurel Committed by Jérome Perrin

xhtml_style: adjust standard_error_message for Zope4

There are some few differences:

In Zope4 exceptions are callable, but we don't want to call them here,
so we use a python: expression instead of the path expression which
tries to call error_value.

error_message is sometimes not passed.

The context is different: 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>, ...]

In case of redirect, the body is no longer empty, but we explicitly
return an empty body to keep the same behavior as zope2
parent c22f7b87
......@@ -4,8 +4,14 @@
it tries to render the error from the web site root. If no web site
root is defined then it renders the error from portal.
"""
from zExceptions import Unauthorized
from zExceptions import Redirect, Unauthorized
if isinstance(kw.get('error_value'), Redirect):
return ''
try:
# Adjust exception context for Zope 4.
context = container.REQUEST.get('PARENTS', [context])[0]
return context.standard_error_message_template(*args, **kw)
except Unauthorized:
pass
......
......@@ -4,13 +4,13 @@
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
metal:define-macro="standard_error_message_render"
>
<div tal:condition="options/error_message" tal:content="structure options/error_message" />
<div tal:condition="not: options/error_message">
<div tal:condition="python: options.get('error_message')" tal:content="structure options/error_message" />
<div tal:condition="python: not options.get('error_message')">
<h2 i18n:translate="">Site Error</h2>
<p i18n:translate="">An error was encountered while publishing this resource.</p>
<p>
<strong i18n:translate="">Error Type: <span tal:replace="options/error_type" i18n:name="error_type" /></strong><br />
<strong i18n:translate="">Error Value: <span tal:replace="options/error_value" i18n:name="error_value" /></strong><br />
<strong i18n:translate="">Error Value: <span tal:replace="python: str(options['error_value'])" i18n:name="error_value" /></strong><br />
</p>
<hr noshade="noshade" />
<p i18n:translate="">Troubleshooting Suggestions</p>
......
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