[Zope-CMF] standard_error_message as python script calling page template in CMF

Grégoire Weber gregoire.weber@switzerland.org
Sun, 19 May 2002 01:54:08 +0200


Hi people,

I'd like to show different standard_error_messages depending if
a user is authenticated or not. I'd like to use page templates.

I had the idea to call the page templates ('std_err_msg_auth' and
'std_err_msg_anon') through a Python Script named
'standard_error_message'.

# python script code of standard_error_message
# in the custom skin path
if context.portal_membership.isAnonymousUser():
     return getattr(context, 'std_err_msg_anon')()
else:
     return getattr(context, 'std_err_msg_auth')()

'std_err_msg_anon' and 'std_err_msg_auth' are very simple:
<html><head></head>
<body>
<b tal:content="template/title_or_id"></b>
</body>
</html>

The ZPT and the Python Script are in the custom skin folder.

Calling standard_error_message by clicking the Test tab in
the ZMI works.

Accessing a not existing page delivers a NotFound error message
from the publisher (?, the one without <html> at the beginning)
because it seems my standard_error_message script generates itself
an error.

What's different in the case of an error?

I read on the mailing list that you should not take Python Scripts
as standard_error_message objects (cumbersome for me). Is that
right?

I don't like to use DTML if possible.

Any advices?

Greetings, Greg