[Zope] how to catch the error message following the failed
login via dtm l-try dtml-except
11 Jun 2003 10:58:54 -0700
First off, I wouldn't use AUTHENTICATED_USER, it's deprecated.
Second, DTML works a better if you test for the existence of a variable
rather than just trapping for its absence (unlike Python).
<dtml-if foo> tests not only for the *truth* of foo, but its existence.
I'd suggest the following:
<dtml-if "_.SecurityGetUser().getUserName() != 'Anonymous User'">
Restricted content / method goes here
Sorry, this content is restricted
More simply, you could also use permissions to restrict object usage to
On Wed, 2003-06-11 at 08:07, Deniz, Metin wrote:
> Hello everybody,
> I have the following problem:
> I have created a website which is generally accessible to everybody without
> the need to login(user = anonymous).
> Some areas of the site are reserved only to users who have an account in the
> acl users folders.
> 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.
> You are not authorized to access this resource.
> Traceback (innermost last):
> File C:\Zope\lib\python\ZPublisher\Publish.py, line 150, in publish_module
> File C:\Zope\lib\python\ZPublisher\Publish.py, line 114, in publish
> File C:\Zope\lib\python\Zope\__init__.py, line 158, in
> (Object: logintest)
> 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
> Unauthorized: (see above)
> Here is the example code which produces this error:
> <dtml-var standard_html_header>
> User: <dtml-var "AUTHENTICATED_USER.getUserName()">
> Failed to login
> <dtml-var standard_html_footer>
> Unfortunatelly it does not work. Instead I just get the above error message.
> Do you have any idea as how to do it?
> Metin Deniz
> Zope maillist - Zope@zope.org
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-dev )