[Zope] Per error error page
Clemens Klein-Robbenhaar
zope@zope.org
Wed, 11 Sep 2002 18:18:35 +0200 (CEST)
Hi Jim,
seems Dieter is on vacation :), and nobody else has answered Your question
(or I missed the reply ...). I guess the question is answered on some
FAQ, but I could not find it ...
Anyway, I try to give an answer:
> Is it possible to have an error page display a different message depending
> on what happened?
The most flexible solution is to define a python script with name
'standard_error_message' replacing the original error message template,
which is moved to 'general_error_message', and called by the script if
this could not find a more special error page.
>
> For example, we have a user-friendly page template for the
> standard_error_message, but it displays the same content for 404 errors and
> for script errors. Ideally I'd like to be able to say one message for 404
> errors, and another for script errors.
[...]
The script could look like this:
## Script (Python) "standard_error_message"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=error_type=None, error_value=None, error_traceback=None, error_tb=None, error_message=None
##title=
##
if str(error_type) == 'NotFound':
error_page = context.not_found
else:
error_page = context.general_error_message
return error_page(error_type=error_type,
error_value=error_type,
error_message=error_message,
error_traceback=error_traceback,
error_tb=error_tb)
(error_traceback and error_tb usually refer to the same object, the
trace back, I guess.)
I do not know if there is a more elegant solution (passing all the
keyword arguments around explicitly looks clumsy but seems to be
necessary to access them properly.)
Cheers,
Clemens