Class
zope.app.security.vocabulary.PermissionIdsVocabulary

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 zope.app.testing.placelesssetup 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 zope.security.interfaces import IPermission
>>> from zope.security.permission import Permission
>>> from zope.app.testing 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
u'a'
>>> vocab.getTermByToken('b').value
u'b'

However, the public permission value is CheckerPublic:

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

and its title is shortened:

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

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

Attributes/Properties

There are no attributes in this class.

Methods

Known Subclasses

There are no known subclasses.