[Zope] Detecting Roles not working

Peter Bengtsson peter@grenna.net
Wed, 4 Oct 2000 21:10:54 +0100


Stolen somewhere from this list, and I don't remember from who.

<dtml-if "AUTHENTICATED_USER.has_permission('Edit', this())">

...is cool to have as well if you ever need it.
Let's you not use specific names of ACL's such as "Staff" or "CopyWriter".



> <dtml-if "AUTHENTICATED_USER.has_role('Staff', this())">
> 
> This works for me, no pun intended :)
> 
> Dan
> 
> Kapil Thangavelu wrote:
> > 
> > Jonathan Cheyne wrote:
> > >
> > > Hi all
> > >
> > > I have built the basis of a site with full, form-based webediting of
> > > objects. Coming round to cleanup time and I wanted to remove certain
> > > visible functions from the default object views unless you have already
> > > logged in (with various possible roles)
> > >
> > > in the index_html of my zclass i have
> > >
> > > <dtml-if "AUTHENTICATED_USER.has_role('Staff')">
> > > <a href="<dtml-var absolute_url>/<dtml-var type>edit">edit this</a><hr>
> > > </dtml-if>
> > > so if the user is anonymous or logged in without the Staff role assigne
> > > they should not see the "edit this" link ...
> > >
> > > Doesn't work! It basically never returns a 'true' response thus never
> > > displays the edit this link even when logged in.
> > 
> > try (untested)
> > 
> > <dtml-if "AUTHENTICATED_USER.has_role('Staff')==1"
> > 
> > or (tested)
> > 
> > <dtml-if "'Staff' in AUTHENTICATED_USER.getRoles()">
> > 
> > Cheers
> > 
> > Kapil
> > 
> > _______________________________________________
> > Zope maillist  -  Zope@zope.org
> > http://lists.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://lists.zope.org/mailman/listinfo/zope-announce
> >  http://lists.zope.org/mailman/listinfo/zope-dev )
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>