Utility-based Vocabulary Registry
Project description
This Zope 3 package provides a zope.schema vocabulary registry that uses utilities to look up vocabularies.
Component-based Vocabulary Registry
This package provides a vocabulary registry for zope.schema, based on the component architecture.
It replaces the zope.schema’s simple vocabulary registry when zope.app.schema package is imported, so it’s done automatically. All we need is provide vocabulary factory utilities:
>>> from zope.component import provideUtility >>> from zope.schema.interfaces import IVocabularyFactory >>> from zope.schema.vocabulary import SimpleTerm >>> from zope.schema.vocabulary import SimpleVocabulary>>> def SomeVocabulary(context=None): ... terms = [SimpleTerm(1), SimpleTerm(2)] ... return SimpleVocabulary(terms)>>> provideUtility(SomeVocabulary, IVocabularyFactory, ... name='SomeVocabulary')
Now we can get the vocabulary using standard zope.schema way:
>>> from zope.schema.vocabulary import getVocabularyRegistry >>> vr = getVocabularyRegistry() >>> voc = vr.get(None, 'SomeVocabulary') >>> [term.value for term in voc] [1, 2]
CHANGES
1.0.0 (2013-03-01)
Added support for Python 3.3.
Replaced deprecated zope.interface.implements usage with equivalent zope.interface.implementer decorator.
Dropped support for Python 2.4 and 2.5.
Initial release independent of zope.app.schema.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for zope.vocabularyregistry-1.0.0.zip
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d521765c44a8e7a19551fe95146fa2bac297f805f9b758cdbef9b54db0a8692 |
|
MD5 | d46f656d46d38de0694dd810670617a5 |
|
BLAKE2b-256 | ee3db49570dfa585231545704aca369f551aa8e908d8c6778d0dd68eedd33e66 |