Utility-based Vocabulary Registry
Project description
zope.vocabularyregistry
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.vocabularyregistry package is imported, so it’s done automatically. All we need is provide vocabulary factory utilities:
>>> import zope.vocabularyregistry >>> 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]
Configuration
This package provides configuration that ensures the vocabulary registry is established:
>>> from zope.configuration import xmlconfig >>> _ = xmlconfig.string(r""" ... <configure xmlns="http://namespaces.zope.org/zope" i18n_domain="zope"> ... <include package="zope.vocabularyregistry" /> ... </configure> ... """)
CHANGES
1.1.0 (2018-11-30)
Ensure that a convtext is provided when looking up the vocabulary factory.
Drop support for Python 2.6 and 3.3.
Add support for Python 3.5, 3.6, 3.7, PyPy and PyPy3.
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
Built Distribution
Hashes for zope.vocabularyregistry-1.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43741befbe999a24076f1aa2393a9aa7aa38e40c09b123a1315344bab2ba4250 |
|
MD5 | 7fed3b169f3fff2a57c0aa8a52f6ea70 |
|
BLAKE2b-256 | e11ecfa3dd805f76118c9032171f80ecfa00eeac854880a64308f60f679a1a5a |
Hashes for zope.vocabularyregistry-1.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1881f6b25dcca580f0d279e176f74e6c9a0a5f80c99bc2b0f15b7298ab653883 |
|
MD5 | c8941d3cc44037c6f06266d5bde88c1d |
|
BLAKE2b-256 | e3064b6368aa2f2b6bf34a00a40ccfecc0ef3f2fb26dc55d6da63542a41f1e73 |