[Zope-CMF] Help with user roles
Ken Manheimer
klm@digicool.com
Wed, 11 Apr 2001 15:36:24 -0400 (EDT)
On Wed, 11 Apr 2001, Adrian Madrid wrote:
> Sorry to repost this but I haven't figured out yet how
> to programatically find out if a user has certain
> role. I've received some help from Tres but I can't
> figure out how to use it in a script. Here goes what
> he shared.
>
> > In a PythonScript which binds '_' to the DTML
> > namespace:
> >
> > # Get all roles defined in user folder.
> > _.SecurityManager().getUser().getRoles()
> >
> > # Get all roles pertaining to an object, 'foo'
> > _.SecurityGetUser().getRolesInContext( foo )
>
> If anybody figured out how to tell if the auth user
> has certain role _please_ share the zen with me/us.
I must be missing something - how does a construct like:
if 'Member' in _.SecurityGetUser().getRolesInContext(foo):
...
fall short for you? (The same thing could be done for getRoles() - the
difference is whether you want the roles within the context of a
particular object or not...)
Ken Manheimer
klm@digicool.com