{ "info": { "author": "Zope Corporation and Contributors", "author_email": "zope-dev@zope.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Zope :: 3", "Intended Audience :: Developers", "License :: OSI Approved :: Zope Public License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Internet :: WWW/HTTP" ], "description": "=========================\n zope.vocabularyregistry\n=========================\n\n.. image:: https://img.shields.io/pypi/v/zope.vocabularyregistry.svg\n :target: https://pypi.python.org/pypi/zope.vocabularyregistry/\n :alt: Latest release\n\n.. image:: https://img.shields.io/pypi/pyversions/zope.vocabularyregistry.svg\n :target: https://pypi.org/project/zope.vocabularyregistry/\n :alt: Supported Python versions\n\n.. image:: https://travis-ci.org/zopefoundation/zope.vocabularyregistry.svg?branch=master\n :target: https://travis-ci.org/zopefoundation/zope.vocabularyregistry\n\n.. image:: https://coveralls.io/repos/github/zopefoundation/zope.vocabularyregistry/badge.svg?branch=master\n :target: https://coveralls.io/github/zopefoundation/zope.vocabularyregistry?branch=master\n\n\nThis Zope 3 package provides a ``zope.schema`` vocabulary registry that uses\nutilities to look up vocabularies.\n\n\n=====================================\n Component-based Vocabulary Registry\n=====================================\n\nThis package provides a vocabulary registry for zope.schema,\nbased on the component architecture.\n\nIt replaces the zope.schema's simple vocabulary registry\nwhen ``zope.vocabularyregistry`` package is imported, so it's done\nautomatically. All we need is provide vocabulary factory\nutilities:\n\n >>> import zope.vocabularyregistry\n >>> from zope.component import provideUtility\n >>> from zope.schema.interfaces import IVocabularyFactory\n >>> from zope.schema.vocabulary import SimpleTerm\n >>> from zope.schema.vocabulary import SimpleVocabulary\n\n >>> def makeVocabularyFactory(*values):\n ... def vocabularyFactory(context=None):\n ... terms = [SimpleTerm(v) for v in values]\n ... return SimpleVocabulary(terms)\n ... return vocabularyFactory\n\n >>> zope.component.provideUtility(\n ... makeVocabularyFactory(1, 2), IVocabularyFactory,\n ... name='SomeVocabulary')\n\nNow we can get the vocabulary using standard zope.schema\nway:\n\n >>> from zope.schema.vocabulary import getVocabularyRegistry\n >>> vr = getVocabularyRegistry()\n >>> voc = vr.get(None, 'SomeVocabulary')\n >>> [term.value for term in voc]\n [1, 2]\n\n\nIf vocabulary is not found, VocabularyRegistryError is raised.\n\n >>> try:\n ... vr.get(None, 'NotAvailable')\n ... except LookupError as error:\n ... print(\"%s.%s: %s\" % (error.__module__, error.__class__.__name__, error))\n zope.schema.vocabulary.VocabularyRegistryError: unknown vocabulary: 'NotAvailable'\n\n\nWe can also use vocabularies defined in local component registries.\nLet's define some local sites with a vocabulary.\n\n >>> import zope.component.hooks\n >>> from zope.component import globalregistry\n >>> from zope.component.globalregistry import getGlobalSiteManager\n\n >>> from zope.interface.registry import Components\n >>> class LocalSite(object):\n ... def __init__(self, name):\n ... self.sm = Components(\n ... name=name, bases=(globalregistry.getGlobalSiteManager(), ))\n ...\n ... def getSiteManager(self):\n ... return self.sm\n\n >>> local_site_even = LocalSite('local_site_even')\n >>> local_site_even.sm.registerUtility(\n ... makeVocabularyFactory(4, 6, 8), IVocabularyFactory,\n ... name='SomeVocabulary', event=False)\n\n >>> local_site_odd = LocalSite('local_site_odd')\n >>> local_site_odd.sm.registerUtility(\n ... makeVocabularyFactory(3, 5, 7), IVocabularyFactory,\n ... name='SomeVocabulary', event=False)\n\n\nVocabularies defined in local component registries can be accessed\nin two ways.\n\n1. Using the registry from within a site.\n\n >>> with zope.component.hooks.site(local_site_even):\n ... voc = getVocabularyRegistry().get(None, 'SomeVocabulary')\n ... [term.value for term in voc]\n [4, 6, 8]\n\n2. Binding to a context that can be used to look up a local site manager.\n\n >>> from zope.interface.interfaces import IComponentLookup\n >>> zope.component.provideAdapter(\n ... lambda number: ((local_site_even, local_site_odd)[number % 2]).sm,\n ... adapts=(int, ), provides=IComponentLookup)\n\n >>> context = 4\n >>> voc = getVocabularyRegistry().get(context, 'SomeVocabulary')\n >>> [term.value for term in voc]\n [4, 6, 8]\n\nBinding to a context takes precedence over active site, so we can look\nup vocabularies from other sites.\n\n >>> context = 7\n >>> with zope.component.hooks.site(local_site_even):\n ... voc = getVocabularyRegistry().get(context, 'SomeVocabulary')\n ... [term.value for term in voc]\n [3, 5, 7]\n\n\nIf we cannot find a local site for given context, currently active\nsite is used.\n\n >>> from zope.interface.interfaces import ComponentLookupError\n >>> def raisingGetSiteManager(context=None):\n ... if context == 42:\n ... raise ComponentLookupError(context)\n ... return zope.component.hooks.getSiteManager(context)\n >>> hook = zope.component.getSiteManager.sethook(raisingGetSiteManager)\n\n >>> context = 42\n >>> with zope.component.hooks.site(local_site_odd):\n ... voc = getVocabularyRegistry().get(context, 'SomeVocabulary')\n ... [term.value for term in voc]\n [3, 5, 7]\n\n\nConfiguration\n=============\n\nThis package provides configuration that ensures the vocabulary\nregistry is established:\n\n\n >>> from zope.configuration import xmlconfig\n >>> _ = xmlconfig.string(r\"\"\"\n ... \n ... \n ... \n ... \"\"\")\n\n\n=========\n CHANGES\n=========\n\n1.1.1 (2018-12-03)\n==================\n\n- Important bugfix for the new feature introduced in 1.1.0: Fall back to\n active site manager if no local site manager can be looked up for provided\n context.\n\n\n1.1.0 (2018-11-30)\n==================\n\n- Ensure that a convtext is provided when looking up the vocabulary factory.\n\n- Drop support for Python 2.6 and 3.3.\n\n- Add support for Python 3.5, 3.6, 3.7, PyPy and PyPy3.\n\n\n1.0.0 (2013-03-01)\n==================\n\n- Added support for Python 3.3.\n\n- Replaced deprecated ``zope.interface.implements`` usage with equivalent\n ``zope.interface.implementer`` decorator.\n\n- Dropped support for Python 2.4 and 2.5.\n\n- Initial release independent of ``zope.app.schema``.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/zopefoundation/zope.vocabularyregistry", "keywords": "zope3 schema vocabulary registry", "license": "ZPL 2.1", "maintainer": "", "maintainer_email": "", "name": "zope.vocabularyregistry", "package_url": "https://pypi.org/project/zope.vocabularyregistry/", "platform": "", "project_url": "https://pypi.org/project/zope.vocabularyregistry/", "project_urls": { "Homepage": "http://github.com/zopefoundation/zope.vocabularyregistry" }, "release_url": "https://pypi.org/project/zope.vocabularyregistry/1.1.1/", "requires_dist": [ "setuptools", "zope.component", "zope.interface", "zope.schema", "zope.configuration ; extra == 'test'", "zope.testing ; extra == 'test'", "zope.testrunner ; extra == 'test'" ], "requires_python": "", "summary": "Utility-based Vocabulary Registry", "version": "1.1.1" }, "last_serial": 4554577, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "d46f656d46d38de0694dd810670617a5", "sha256": "0d521765c44a8e7a19551fe95146fa2bac297f805f9b758cdbef9b54db0a8692" }, "downloads": -1, "filename": "zope.vocabularyregistry-1.0.0.zip", "has_sig": false, "md5_digest": "d46f656d46d38de0694dd810670617a5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14553, "upload_time": "2013-03-01T22:44:57", "url": "https://files.pythonhosted.org/packages/ee/3d/b49570dfa585231545704aca369f551aa8e908d8c6778d0dd68eedd33e66/zope.vocabularyregistry-1.0.0.zip" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "c8941d3cc44037c6f06266d5bde88c1d", "sha256": "1881f6b25dcca580f0d279e176f74e6c9a0a5f80c99bc2b0f15b7298ab653883" }, "downloads": -1, "filename": "zope.vocabularyregistry-1.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c8941d3cc44037c6f06266d5bde88c1d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7994, "upload_time": "2018-11-30T16:24:10", "url": "https://files.pythonhosted.org/packages/e3/06/4b6368aa2f2b6bf34a00a40ccfecc0ef3f2fb26dc55d6da63542a41f1e73/zope.vocabularyregistry-1.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7fed3b169f3fff2a57c0aa8a52f6ea70", "sha256": "43741befbe999a24076f1aa2393a9aa7aa38e40c09b123a1315344bab2ba4250" }, "downloads": -1, "filename": "zope.vocabularyregistry-1.1.0.tar.gz", "has_sig": false, "md5_digest": "7fed3b169f3fff2a57c0aa8a52f6ea70", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8220, "upload_time": "2018-11-30T16:24:12", "url": "https://files.pythonhosted.org/packages/e1/1e/cfa3dd805f76118c9032171f80ecfa00eeac854880a64308f60f679a1a5a/zope.vocabularyregistry-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "60c68d3f883dbdf89abc0ef64fd641f2", "sha256": "8d1cdf040729c3f9b72584c3a02a517c141b9d9c4845ea868b760c36423fb761" }, "downloads": -1, "filename": "zope.vocabularyregistry-1.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "60c68d3f883dbdf89abc0ef64fd641f2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9998, "upload_time": "2018-12-03T07:05:11", "url": "https://files.pythonhosted.org/packages/a3/85/a18a08f8a53e62d86c53a7ff33459b2ce32922d30a4897175f1a57119ae9/zope.vocabularyregistry-1.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fea2d13df826ea4e203e535ecac449a4", "sha256": "7852edd23806077bafdbcc097dd6bd7b2f0bc0ec0f6851e3ef75b353566c1349" }, "downloads": -1, "filename": "zope.vocabularyregistry-1.1.1.tar.gz", "has_sig": false, "md5_digest": "fea2d13df826ea4e203e535ecac449a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9850, "upload_time": "2018-12-03T07:05:13", "url": "https://files.pythonhosted.org/packages/7a/55/3f7c48a505a225d0558730f67e9ff500ab943bee0b576b40cd179b7442a0/zope.vocabularyregistry-1.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "60c68d3f883dbdf89abc0ef64fd641f2", "sha256": "8d1cdf040729c3f9b72584c3a02a517c141b9d9c4845ea868b760c36423fb761" }, "downloads": -1, "filename": "zope.vocabularyregistry-1.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "60c68d3f883dbdf89abc0ef64fd641f2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9998, "upload_time": "2018-12-03T07:05:11", "url": "https://files.pythonhosted.org/packages/a3/85/a18a08f8a53e62d86c53a7ff33459b2ce32922d30a4897175f1a57119ae9/zope.vocabularyregistry-1.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fea2d13df826ea4e203e535ecac449a4", "sha256": "7852edd23806077bafdbcc097dd6bd7b2f0bc0ec0f6851e3ef75b353566c1349" }, "downloads": -1, "filename": "zope.vocabularyregistry-1.1.1.tar.gz", "has_sig": false, "md5_digest": "fea2d13df826ea4e203e535ecac449a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9850, "upload_time": "2018-12-03T07:05:13", "url": "https://files.pythonhosted.org/packages/7a/55/3f7c48a505a225d0558730f67e9ff500ab943bee0b576b40cd179b7442a0/zope.vocabularyregistry-1.1.1.tar.gz" } ] }