Class
zope.securitypolicy.vocabulary.RoleIdsVocabulary

A vocabular of role IDs.

Term values are the role ID strings Term are stored by title

To illustrate, we need to register the role IDs vocab:

>>> from zope.app.testing.placelesssetup import setUp, tearDown
>>> setUp()
>>> from zope.schema.vocabulary import getVocabularyRegistry
>>> registry = getVocabularyRegistry()
>>> registry.register('Role Ids', RoleIdsVocabulary)

Let's register some sample roles to test against them

>>> from zope.securitypolicy.interfaces import IRole
>>> from zope.securitypolicy.role import Role
>>> from zope.app.testing import ztapi
>>> ztapi.provideUtility(IRole, Role('a_id','a_title'), 'a_id')
>>> ztapi.provideUtility(IRole, Role('b_id','b_title'), 'b_id')

Let's lookup the roles using the vocabulary

>>> vocab = registry.get(None, 'Role Ids')
>>> vocab.getTermByToken('a_id').value
u'a_id'
>>> vocab.getTermByToken('b_id').value
u'b_id'
>>> tearDown()

Base classes

Implemented Interfaces

Attributes/Properties

There are no attributes in this class.

Methods

Known Subclasses

There are no known subclasses.