A vocabulary that provides a list of all interfaces that its context provides.
Here a quick demonstration:
>>> from zope.interface import Interface, implements >>> class I1(Interface): ... pass >>> class I2(Interface): ... pass >>> class I3(I2): ... pass
>>> class Object(object): ... implements(I3, I1)
>>> vocab = ObjectInterfacesVocabulary(Object()) >>> import pprint >>> names = [term.token for term in vocab] >>> names.sort() >>> pprint.pprint(names) ['zope.app.interface.vocabulary.I1', 'zope.app.interface.vocabulary.I2', 'zope.app.interface.vocabulary.I3', 'zope.interface.Interface']
There are no attributes in this class.
createTerm(cls, *args)
Create a single term from data.
Subclasses may override this with a class method that creates a term of the appropriate type from the arguments.
fromItems(cls, items, *interfaces)
Construct a vocabulary from a list of (token, value) pairs.
The order of the items is preserved as the order of the terms in the vocabulary. Terms are created by calling the class method createTerm() with the pair (value, token).
One or more interfaces may also be provided so that alternate widgets may be bound without subclassing.
fromValues(cls, values, *interfaces)
Construct a vocabulary from a simple list.
Values of the list become both the tokens and values of the terms in the vocabulary. The order of the values is preserved as the order of the terms in the vocabulary. Tokens are created by calling the class method createTerm() with the value as the only parameter.
One or more interfaces may also be provided so that alternate widgets may be bound without subclassing.
getTerm(value)
See zope.schema.interfaces.IBaseVocabulary
getTermByToken(token)
See zope.schema.interfaces.IVocabularyTokenized