{ "info": { "author": "Rok Garbas", "author_email": "rok@garbas.si", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: GNU General Public License (GPL)", "Programming Language :: Python", "Programming Language :: Zope" ], "description": "Introduction\n============\n\nLike elephants don't forget anything, so does not\n``collective.elephantvocabulary``. It provides a wrapper around for existing\n`zope.schema`_ vocabularies and make them not forget anything.\n\nExample usecase would be a vocabulary (source) of users which from certain\npoint in time wants to hide / deactivate some users for form or listing. But\nat the same time you want keep old references to user term working. This is\nwhere ``collective.elephantvocabulary`` comes into the picture. With it you\nwrap existing vocabulary of users and provide set of hidden list of users\n(term values).\n\n\n.. contents::\n\n.. _`zope.schema`: http://pypi.python.org/pypi/zope.schema\n\n\nUsage\n=====\n\nSome example content and vocabularies\n\n >>> context = layer.context\n >>> example_vocab = layer.example_vocab\n >>> example_source = layer.example_source\n >>> [i.value for i in example_vocab]\n [1, 2, 3, 4]\n\nBelow is out wraper method we use to make our existing vocab more\nelephant-like.\n\n >>> from collective.elephantvocabulary import wrap_vocabulary\n\nIn first exampe we pass to our ``wrap_vocabulary`` a vocabulary of\n[1, 2, 3, 4] and we set terms 2 and 3 to hidden. ``wrap_vocabulary``\nreturns ``VocabularyFactory`` which needs to be called with context\n(you could also register it with as utility).\n\n >>> wrapped_vocab_factory = wrap_vocabulary(example_vocab, hidden_terms=[2, 3])\n >>> print wrapped_vocab_factory\n \n\n >>> wrapped_vocab = wrapped_vocab_factory(context)\n >>> [i.value for i in wrapped_vocab]\n [1, 4]\n\n >>> len(wrapped_vocab) == len(example_vocab)\n True\n\n >>> 2 in wrapped_vocab\n True\n\n >>> 5 in wrapped_vocab\n False\n\n >>> wrapped_vocab.getTerm(3).value\n 3\n\nSimilar we can limit items shown only to the set we want (via\n``visible_terms``)\n\n >>> wrapped_vocab = wrap_vocabulary(example_vocab,\n ... visible_terms=[2, 3])(context)\n >>> [i.value for i in wrapped_vocab]\n [2, 3]\n\n >>> len(wrapped_vocab) == len(example_vocab)\n True\n\n >>> 2 in wrapped_vocab\n True\n\n >>> 5 in wrapped_vocab\n False\n\n >>> wrapped_vocab.getTerm(1).value\n 1\n\nAbove we see what ``collective.elephantvocabulary`` is all about. When listing\nvocabulary hidden terms are not listed. But when item is requested with its\nterm value then term is also returned. Also length of vocabulary is unchanged.\nIt still shows original lenght of vocabulary.\n\nWe can also call vocabulary by name it was register with ZCA machinery..\n\n >>> wrapped_vocab = wrap_vocabulary('example-vocab',\n ... hidden_terms=[2, 3])(context)\n >>> [i.value for i in wrapped_vocab]\n [1, 4]\n\n``hidden_terms`` or ``visible_terms`` parameter (second argument we pass to\n``wrap_vocabulary``) can also be callable which expects 2 parameters,\n``context`` and ``original vocabulary``.\n\n >>> def hidden_terms(context, vocab):\n ... return [1, 4]\n\n >>> wrapped_vocab = wrap_vocabulary(example_vocab,\n ... hidden_terms=hidden_terms)(context)\n >>> [i.value for i in wrapped_vocab]\n [2, 3]\n\n >>> def visible_terms(context, vocab):\n ... return [1, 4]\n\n >>> wrapped_vocab = wrap_vocabulary(example_vocab,\n ... visible_terms=hidden_terms)(context)\n >>> [i.value for i in wrapped_vocab]\n [1, 4]\n\n``collective.elephantvocabulary`` also works with sources.\n\n >>> [i.value for i in example_source]\n [1, 2, 3, 4]\n\n >>> [i.value for i in example_source.search()]\n [1, 2]\n\n >>> wrapped_source = wrap_vocabulary(example_source, hidden_terms=[1, 4])(context)\n >>> [i.value for i in wrapped_source.search()]\n [2]\n\n >>> wrapped_source = wrap_vocabulary(example_source, visible_terms=[1, 4])(context)\n >>> [i.value for i in wrapped_source.search()]\n [1]\n\nIf vocabulary already provides set of hidden terms they are passed to wrapped\nvocabulary.\n\n >>> example_vocab.hidden_terms = [1, 2]\n >>> wrapped_vocab = wrap_vocabulary(example_vocab)(context)\n >>> [i.value for i in wrapped_vocab]\n [3, 4]\n\n\n >>> del example_vocab.hidden_terms\n\n >>> example_vocab.visible_terms= [1, 2]\n >>> wrapped_vocab = wrap_vocabulary(example_vocab)(context)\n >>> [i.value for i in wrapped_vocab]\n [1, 2]\n\n >>> del example_vocab.visible_terms\n\nVocabulary will ass to the list of passed ``visible_terms`` or ``hidden_terms``.\n\n >>> example_vocab.hidden_terms = [1, 2]\n >>> wrapped_vocab = wrap_vocabulary(example_vocab,\n ... hidden_terms=[2, 3])(context)\n >>> [i.value for i in wrapped_vocab]\n [4]\n\n\n >>> del example_vocab.hidden_terms\n\n >>> example_vocab.visible_terms= [1]\n >>> wrapped_vocab = wrap_vocabulary(example_vocab,\n ... visible_terms=[1, 2, 3])(context)\n >>> [i.value for i in wrapped_vocab]\n [1, 2, 3]\n\n >>> del example_vocab.visible_terms\n\n``hidden_terms`` and ``visible_terms`` can also work together.\n\n >>> wrapped_vocab = wrap_vocabulary(example_vocab,\n ... visible_terms=[1, 2, 3],\n ... hidden_terms=[2])(context)\n >>> [i.value for i in wrapped_vocab]\n [1, 3]\n\nWe could also store ``hidden_terms`` and ``visible_terms`` in\n`plone.registry`_. Instead of creating our own methods which reads from\nplone.registry ``collective.elephantvocabulary`` provides helper parameters:\n``hidden_terms_from_registry`` and ``visible_terms_from_registry``.\n\n >>> from zope.component import getUtility\n >>> from plone.registry import field\n >>> from plone.registry import Record\n >>> from plone.registry.interfaces import IRegistry\n\n >>> example_registry_record = Record(\n ... field.List(title=u\"Test\", min_length=0, max_length=10,\n ... value_type=field.Int(title=u\"Value\")))\n >>> example_registry_record.value = [1, 2]\n\n >>> registry = getUtility(IRegistry)\n >>> registry.records['example.hidden_terms'] = example_registry_record\n >>> registry.records['example.visible_terms'] = example_registry_record\n\n >>> wrapped_vocab = wrap_vocabulary(example_vocab,\n ... visible_terms_from_registry='example.visible_terms')(context)\n >>> [i.value for i in wrapped_vocab]\n [1, 2]\n\n >>> wrapped_vocab = wrap_vocabulary(example_vocab,\n ... hidden_terms_from_registry='example.hidden_terms')(context)\n >>> [i.value for i in wrapped_vocab]\n [3, 4]\n\nOr we can use them in combination.\n\n >>> example_registry_record2 = Record(\n ... field.List(title=u\"Test\", min_length=0, max_length=10,\n ... value_type=field.Int(title=u\"Value\")))\n >>> example_registry_record2.value = [1, 2, 3]\n >>> registry.records['example.visible_terms'] = example_registry_record2\n\n >>> wrapped_vocab = wrap_vocabulary(example_vocab,\n ... visible_terms_from_registry='example.visible_terms',\n ... hidden_terms_from_registry='example.hidden_terms')(context)\n >>> [i.value for i in wrapped_vocab]\n [3]\n\nAnd if we don't pass anything to ``wrap_vocabulary`` then it should ack as\nnormal vocabulary.\n\n >>> wrapped_vocab5 = wrap_vocabulary(example_vocab)(context)\n >>> [i.value for i in wrapped_vocab5]\n [1, 2, 3, 4]\n\n.. _`plone.registry`: http://pypi.python.org/pypi/plone.registry\n\n\nCredits\n=======\n\nGenerously sponsored by `4teamwork`_.\n\n * `Rok Garbas`_, author\n\n\nTodo\n====\n\n * provide test / documentation for custom wrapper class\n * coverage should show 100%, but its failing on method and import lines, weird.\n\n.. _`Rok Garbas`: http://www.garbas.si\n.. _`4teamwork`: http://4teamwork.ch\n\n\nHistory\n=======\n\n0.2.5 (2015-03-21)\n------------------\n\n- Whitespaces cleanup.\n [gforcada]\n\n\n0.2.4 (2013-10-26)\n------------------\n\n * fixing 0.2.3 release\n [garbas]\n\n0.2.3 (2013-10-25)\n------------------\n\n * Don't memoize the persistent plone.registry utility. This avoids issues\n with object access across different ZODB connections (see issue #2).\n [lgraf]\n\n * Avoid nesting internal term lists (see issue #3). [lgraf]\n\n * Avoid indefinite growth of internal term lists (see issue #4). [lgraf]\n\n * Split the ``README.rst`` up into several files. Put the testing\n part in ``tests.rst`` in the main directory so this test file can also\n be found when we are distributed on PyPI. [maurits]\n\n0.2.2 (2010-10-12)\n------------------\n\n * support for other type of vocabs (IVocabulary, IIterableSource) [garbas]\n * BUG(Fixed): registry should be not be loaded at __init__ time [garbas]\n\n0.2.1 (2010-10-11)\n------------------\n\n * new parameters ``visible_terms_from_registry`` and\n ``hidden_terms_from_registry`` which reads values directly from\n `plone.registry`_. [garbas]\n\n0.2 (2010-10-11)\n----------------\n\n * visible_terms parameter added to ``wrap_vocabulary``, by default visible_terms\n and hidden_terms work \"together\" (via WrapperBase) [garbas]\n\n0.1.3 (2010-10-11)\n------------------\n\n * marking wrapper vocabularies with IElephantVocabulary interface [garbas]\n\n0.1.2 (2010-10-08)\n------------------\n\n * misspelled dependency, feeling silly [garbas]\n\n0.1.1 (2010-10-08)\n------------------\n\n * add dependencies from where we import (using `mr.igor`_) [garbas]\n * add link to ``zope.schema`` which was breaking formating for rst\n formatting [garbas]\n * initial release was broken (missing README.rst) [garbas]\n\n0.1 (2010-10-08)\n----------------\n\n * initial release [garbas]\n\n.. _`mr.igor`: http://pypi.python.org/pypi/mr.igor\n.. _`plone.registry`: http://pypi.python.org/pypi/plone.registry", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/collective/collective.elephantvocabulary", "keywords": "zope plone vocabulary", "license": "GPL", "maintainer": null, "maintainer_email": null, "name": "collective.elephantvocabulary", "package_url": "https://pypi.org/project/collective.elephantvocabulary/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/collective.elephantvocabulary/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/collective/collective.elephantvocabulary" }, "release_url": "https://pypi.org/project/collective.elephantvocabulary/0.2.5/", "requires_dist": null, "requires_python": null, "summary": "type of zope vocabularies that dont \"forget\", like elephants", "version": "0.2.5" }, "last_serial": 1471431, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "dfd41caf8a0cbddf38b734149137b1c6", "sha256": "36ad531a5c56e7e3c2c87cba1106e88cf998abcd9152d6f4733170cd2470363b" }, "downloads": -1, "filename": "collective.elephantvocabulary-0.1.tar.gz", "has_sig": false, "md5_digest": "dfd41caf8a0cbddf38b734149137b1c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3872, "upload_time": "2010-10-08T11:28:56", "url": "https://files.pythonhosted.org/packages/41/e6/e3b31c405787277e9b98378b3795ebdc3ceb81c3af2131126af28e240594/collective.elephantvocabulary-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "d8cec0ee1bb093ed55332159b8274aa7", "sha256": "046217d9d129740c74c2e43f668dfe581ccceae2937f71741492e19d8402586e" }, "downloads": -1, "filename": "collective.elephantvocabulary-0.1.1.tar.gz", "has_sig": false, "md5_digest": "d8cec0ee1bb093ed55332159b8274aa7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11138, "upload_time": "2010-10-08T11:55:45", "url": "https://files.pythonhosted.org/packages/e5/c0/9c8f371ed1f56f4e11936fadb17ecbe4d8efe7f05435ccbe8f4e2ec1bfe6/collective.elephantvocabulary-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "b4b29dcce788a5d3eb421d2a4330bcc8", "sha256": "ffcbeba5216669e61ca400a49d51534dc3089ba975b7e1c03b183c97bff07582" }, "downloads": -1, "filename": "collective.elephantvocabulary-0.1.2.tar.gz", "has_sig": false, "md5_digest": "b4b29dcce788a5d3eb421d2a4330bcc8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11190, "upload_time": "2010-10-08T13:45:05", "url": "https://files.pythonhosted.org/packages/c9/3b/68e6f5b937fe2e92372cf8878f4b5f65660df3a4d125eb79746d179da19a/collective.elephantvocabulary-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "c1138eadcc383d8077c7091fd60da4b4", "sha256": "4916d0f95de56715bbb0de1c220c043f21c248fce5268f695cc435246a96973b" }, "downloads": -1, "filename": "collective.elephantvocabulary-0.1.3.tar.gz", "has_sig": false, "md5_digest": "c1138eadcc383d8077c7091fd60da4b4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11332, "upload_time": "2010-10-11T09:29:44", "url": "https://files.pythonhosted.org/packages/19/6a/2ba3c706c41bc5b9b33534c67083ebc755af69986b1941fe8f19f4afa8bf/collective.elephantvocabulary-0.1.3.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "d727bda804dd45bd2bc68c4ee76801a4", "sha256": "6578d9ce3d0f99b16e2d396e0de6fd0e9e58f66fa81e0398527bdd0fc9fd056e" }, "downloads": -1, "filename": "collective.elephantvocabulary-0.2.tar.gz", "has_sig": false, "md5_digest": "d727bda804dd45bd2bc68c4ee76801a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12133, "upload_time": "2010-10-11T12:27:53", "url": "https://files.pythonhosted.org/packages/e8/bb/cfa27f9435bc240ed6dcdbaf7f3c0323ac4c57f8d7f0f662b2d341a07112/collective.elephantvocabulary-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "f9f00dcf11f142a14031e28f05d3c6b8", "sha256": "2a8eaf102fdf27d6e174a8d070188609497d4dc862459dc6b469946231d1c200" }, "downloads": -1, "filename": "collective.elephantvocabulary-0.2.1.tar.gz", "has_sig": false, "md5_digest": "f9f00dcf11f142a14031e28f05d3c6b8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12903, "upload_time": "2010-10-11T19:12:21", "url": "https://files.pythonhosted.org/packages/f8/d7/f6667b665a00cea8b77d49d3658187059b86465f9720d68687b1af839c3b/collective.elephantvocabulary-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "3500527a4c915782ba8fca077985dd19", "sha256": "a663ab4eaad276448015d2600992ef008c2443c53effccd32c0cb2d5747adcdf" }, "downloads": -1, "filename": "collective.elephantvocabulary-0.2.2.tar.gz", "has_sig": false, "md5_digest": "3500527a4c915782ba8fca077985dd19", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13052, "upload_time": "2010-10-12T17:03:23", "url": "https://files.pythonhosted.org/packages/7f/fc/ab2bd958929e1502cda46cd109ec00c22318c2e514144329391c6a898b87/collective.elephantvocabulary-0.2.2.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "1fc1eda562e5237173c11e694e317eaf", "sha256": "6b56b71132ebad135bf5b0c9b64cf9cf3640b96c43e63ba6d0c10100ce2f906c" }, "downloads": -1, "filename": "collective.elephantvocabulary-0.2.4.tar.gz", "has_sig": false, "md5_digest": "1fc1eda562e5237173c11e694e317eaf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14953, "upload_time": "2013-10-26T15:17:32", "url": "https://files.pythonhosted.org/packages/1e/c8/51b327c9aaface0ddbf7f94e06e76659eaa9f3b8155b9d7ad409eb19e246/collective.elephantvocabulary-0.2.4.tar.gz" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "544106fc69dfdacf9ddbb55723d0c2d2", "sha256": "a3f4ef008767007845ac7f792fd468936c192adc33d0be945814b8a609a8c01b" }, "downloads": -1, "filename": "collective.elephantvocabulary-0.2.5.zip", "has_sig": false, "md5_digest": "544106fc69dfdacf9ddbb55723d0c2d2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25714, "upload_time": "2015-03-21T18:28:59", "url": "https://files.pythonhosted.org/packages/93/f1/a86cb423095229d11544199a5cd64151deffdacc85bda28b300ea3ee7602/collective.elephantvocabulary-0.2.5.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "544106fc69dfdacf9ddbb55723d0c2d2", "sha256": "a3f4ef008767007845ac7f792fd468936c192adc33d0be945814b8a609a8c01b" }, "downloads": -1, "filename": "collective.elephantvocabulary-0.2.5.zip", "has_sig": false, "md5_digest": "544106fc69dfdacf9ddbb55723d0c2d2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25714, "upload_time": "2015-03-21T18:28:59", "url": "https://files.pythonhosted.org/packages/93/f1/a86cb423095229d11544199a5cd64151deffdacc85bda28b300ea3ee7602/collective.elephantvocabulary-0.2.5.zip" } ] }