[Zope] testing for local roles

Brian Lloyd Brian@digicool.com
Thu, 13 Jul 2000 17:41:26 -0400


> Is
> <dtml-if "AUTHENTICATED_USER.has_role('Manager','siteManager')">
> ....
> </dtml-if>
> valid for local roles? siteManager is a local role.
> It seems that if I use this and there is a user with a local 
> role present 
> nothing is displayed.
> I'm wondering if there is a has_localrole(....) method of 
> AUTH..._USER but 
> I haven't been able to find it.


Aaron,

The has_role method of User objects can take an optional 
second argument, which is the object to use as context 
(to take local roles into account). Note also that you 
need to pass the list of roles in as sequence. The 
following should do what you expect:

<dtml-if "AUTHENTICATED_USER.has_role(('Manager','siteManager'),
this())">
  ...
</dtml-if>


Brian Lloyd        brian@digicool.com
Software Engineer  540.371.6909              
Digital Creations  http://www.digicool.com