[Zope] problem testing for a permission

Jerome Alet alet@unice.fr
Fri, 20 Apr 2001 10:19:26 +0200 (MET DST)


Hi,

On Thu, 19 Apr 2001, ethan mindlace fremen wrote:

> --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.
> 
> you don't want to evaluate truth: you want to see if there's an exception.
> <dtml-try "AUTHENTICATED_USER.has_permission('View', mymethod)">
>  <A HREF="<dtml-var URL>/mymethod">Members only</A>
> <dtml-except>
>  You are Anonymoose!
> </dtml-try>

Doesn't work, but it's better: the link appears even if the user is
anonymous, but if he clicks on the link then the authentication dialog box
opens. What I want is for the link to not appear at all, if possible.

the permissions on "my_method" are normal, except View which is only
allowed to roles Manager and Member, and not acquired.

Zope version is 2.3.1b2

bye,

Jerome Alet