[Zope] Per error error page
Jim Kutter
jim@ebizq.net
Wed, 11 Sep 2002 12:50:46 -0400
Thanks. But I have a few questions about that.
Where does error_type come from? Isnt' there something in Zope that can tell
me what error occurred (similar to dtml-try, but maybe on a global level -
I'd hate to wrap all pages with try-catch blocks)
And if I provide the error_type how would I know it's a Not Found error?
-jim
----- Original Message -----
From: "Clemens Klein-Robbenhaar" <robbenhaar@espresto.com>
To: "Jim Kutter" <jim@ebizq.net>; <zope@zope.org>
Sent: Wednesday, September 11, 2002 12:18 PM
Subject: [Zope] Per error error page
>
> 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
>