A vocabular of permission IDs.

Term values are the permission ID strings except for 'zope.Public', which is the global permission CheckerPublic.

Term titles are the permission ID strings except for 'zope.Public', which is shortened to 'Public'.

Terms are sorted by title except for 'Public', which always appears as the first term.

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

>>> from import setUp, tearDown
>>> setUp()
>>> from zope.schema.vocabulary import getVocabularyRegistry
>>> registry = getVocabularyRegistry()
>>> registry.register('Permission Ids', PermissionIdsVocabulary)

We also need to register some sample permission utilities, including the special permission 'zope.Public':

>>> from import IPermission
>>> from import Permission
>>> from import ztapi
>>> ztapi.provideUtility(IPermission, Permission('zope.Public'),
...     'zope.Public')
>>> ztapi.provideUtility(IPermission, Permission('b'), 'b')
>>> ztapi.provideUtility(IPermission, Permission('a'), 'a')

We can now lookup these permissions using the vocabulary:

>>> vocab = registry.get(None, 'Permission Ids')

The non-public permissions 'a' and 'b' are string values:

>>> vocab.getTermByToken('a').value
>>> vocab.getTermByToken('b').value

However, the public permission value is CheckerPublic:

>>> vocab.getTermByToken('zope.Public').value is CheckerPublic

and its title is shortened:

>>> vocab.getTermByToken('zope.Public').title

The terms are sorted by title except for the public permission, which is listed first:

>>> [term.title for term in vocab]
[u'Public', u'a', u'b']
>>> tearDown()

Base classes

Implemented Interfaces


There are no attributes in this class.


Known Subclasses

There are no known subclasses.