[Zope] problem testing for a permission

ethan mindlace fremen mindlace@digicool.com
Thu, 19 Apr 2001 22:56:55 -0400


--On Thursday, April 19, 2001 23:01:42 +0200 Jerome Alet <alet@unice.fr> 
wrote:

> <dtml-if "AUTHENTICATED_USER.has_permission('View', mymethod)">
>   ...
>   Some tests and text
>   ...
>   <A HREF="<dtml-var URL>/mymethod">Members only</A>
>   ...
>   Some tests and text
>   ...
> </dtml-if>
>
> but if I access the pages as an anonymous user then I've got
> an Unauthorized exception instead of not having the "Members only" link.
>
> What do I have done wrong ?

you don't want to evaluate truth: you want to see if there's an exception.

I think you want:

<dtml-try "AUTHENTICATED_USER.has_permission('View', mymethod)">
 <A HREF="<dtml-var URL>/mymethod">Members only</A>
<dtml-except>
 You are Anonymoose!
</dtml-try>

Hope that helps,
--
-mindlace-
zopatista community liason