[Grok-dev] How do I get all available roles?

Christian Klinger cklinger at novareto.de
Fri Jul 30 05:27:05 EDT 2010


Hi Sascha,

take a look on this snippet:

http://svn.zope.org/zope.securitypolicy/trunk/src/zope/securitypolicy/vocabulary.py?rev=113057&view=auto

This is a vocabulary which returns all Roles in the specific context.

In your schema you can do it like this:

     role=Set(
         title=u'Allowed Roles',
         description=u'Role Map',
         value_type=Choice(title=u'Role', vocabulary="Role Ids"),
         required=False)


HTH Christian

>   Hi there,
>
> how can I get a list of all available roles? The role manager gives me
> only those roles that have been assigned to users. Roles that are unused
> are not returned by the getPrincipalsAndRoles method.
>
> I need this for a form that is used to create users. The options role
> choice field should be built dynamically according to the roles that are
> available.
>
> Thanks,
> Sascha
>
>
>
> --
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
>
>
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev




More information about the Grok-dev mailing list