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 <dtml-else> Sorry, this content is restricted </dtml-if> -------- More simply, you could also use permissions to restrict object usage to Authenticated Users. HTH, Dylan 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.
Unauthorized
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 zpublisher_exception_hook (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 Unauthorized: (see above)
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>
Unfortunatelly it does not work. Instead I just get the above error message.
Do you have any idea as how to do it?
Regards,
Metin Deniz
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )