[Zope] how to catch the error message following the failed login via dtm l-try dtml-except

Dieter Maurer dieter@handshake.de
Wed, 11 Jun 2003 21:00:06 +0200


Deniz, Metin wrote at 2003-6-11 17:07 +0200:
 > ...
 > When a user tries to access the restricted areas but does not have the right
 > to or pushes the cancel button, then he gets the following error message:
 > 
 > Site Error
 > An error was encountered while publishing this resource. 
 > 
 > Unauthorized
 > ...
 >   File C:\Zope\lib\python\ZPublisher\Publish.py, line 89, in publish
 >   File C:\Zope\lib\python\ZPublisher\BaseRequest.py, line 404, in traverse
 >   File C:\Zope\lib\python\ZPublisher\HTTPResponse.py, line 511, in
 > ...
 > Here is the example code which produces this error:
 > 
 > <dtml-var standard_html_header>
 > <dtml-try>
 >   User:  <dtml-var "AUTHENTICATED_USER.getUserName()">
 > <dtml-except>
 >   Failed to login  
 > </dtml-try>
 > <dtml-var standard_html_footer>

That's not the code that raises the exception.
Instead, the exception is raised in Zope's traversal process,
before it called your object. That's why the "dtml-try" is
not effective.

You can try to customize "standard_error_message"
to send a different page for "Unauthorized" exceptions.


Dieter