Skip to content

Commit

Permalink
check if we can get the site. improve template
Browse files Browse the repository at this point in the history
  • Loading branch information
pbauer committed Nov 3, 2017
1 parent 0596209 commit 80072d8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Products/CMFPlone/browser/exceptions.py
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from AccessControl import getSecurityManager
from OFS.interfaces import IApplication
from Products.Five import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from zExceptions.ExceptionFormatter import format_exception
from zope.component.hooks import getSite

import json
import sys
Expand Down Expand Up @@ -34,8 +34,8 @@ def __call__(self):
'error_type': error_type,
})

if IApplication.providedBy(self.context):
# The context is the Zope-root, so we cannot render our template
if getSite() is None:
# We cannot get the site, so we cannot render our nice template
template = self.basic_template
else:
# Use a simplified template if main_template is not available
Expand Down
26 changes: 21 additions & 5 deletions Products/CMFPlone/browser/templates/basic_error_message.pt
Expand Up @@ -5,17 +5,33 @@
lang="en"
i18n:domain="plone">

<tal:def define="isManager python:view.is_manager()">

<head>
<title>${options/error_type}</title>
<title tal:condition="not:isManager">Error</title>
<title tal:condition="isManager">${options/error_type}</title>
</head>

<body>

<h1>${options/error_type}</h1>
<p>We're sorry, but there seems to be an error.</p>
<h1 class="documentFirstHeading"
i18n:translate="heading_site_error_sorry">
We&#8217;re sorry, but there seems to be an error&hellip;
</h1>

<h2 class="documentFirstHeading"
tal:condition="isManager">${options/error_type}</h2>

<tal:block condition="view/is_manager"
<tal:block condition="isManager"
replace="structure options/error_tb" />
</body>

<tal:noentry condition="not:isManager">
<p i18n:translate="description_site_error_mail_site_admin">
If you are certain you have the correct web address but are encountering an error, please
contact the <span i18n:name="site_admin" i18n:translate="label_site_admin">site administration</span>.
</p>
</tal:noentry>

</body>
</tal:def>
</html>

0 comments on commit 80072d8

Please sign in to comment.