{ "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 :: Zope3", "Intended Audience :: Developers", "License :: OSI Approved :: Zope Public License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "========================\nExtrinsic Key References\n========================\n\nSee ``src/zc/extrinsicreference/README.txt`` for details.\n\n\nDetailed Documentation\n----------------------\n\n====================\nExtrinsic References\n====================\n\nExtrinsic reference registries record a key and one or more values to which\nthey refer. The key and all values must be adaptable to\nzope.app.keyreference.interfaces.IKeyReference.\n\n >>> import zc.extrinsicreference\n >>> references = zc.extrinsicreference.ExtrinsicReferences()\n >>> references.add(1, 2)\n Traceback (most recent call last):\n ...\n TypeError: ('Could not adapt', 1...\n >>> from zope import interface, component\n >>> from zope.app.keyreference.interfaces import IKeyReference\n >>> class IMyObject(interface.Interface):\n ... \"An interface for which we register an IKeyReference adapter\"\n ... id = interface.Attribute(\"An id unique to IMyObject instances\")\n ...\n >>> class MyObject(object):\n ... interface.implements(IMyObject)\n ... _id_counter = 0\n ... @classmethod\n ... def _getId(cls):\n ... val = cls._id_counter\n ... cls._id_counter += 1\n ... return val\n ... def __init__(self):\n ... self.id = self._getId()\n ...\n >>> class DummyKeyReference(object):\n ... interface.implements(IKeyReference)\n ... component.adapts(IMyObject)\n ... key_type_id = 'zc.extrinsicreference.doctest'\n ... def __init__(self, obj):\n ... self.object = obj\n ... def __call__(self):\n ... \"\"\"Get the object this reference is linking to.\n ... \"\"\"\n ... return self.object\n ... def __hash__(self):\n ... \"\"\"Get a unique identifier of the referenced object.\n ... \"\"\"\n ... return hash(self.object.id)\n ... def __cmp__(self, other):\n ... \"\"\"Compare the reference to another reference.\n ... \"\"\"\n ... if self.key_type_id == other.key_type_id:\n ... return cmp(self.object.id, other.object.id)\n ... return cmp(self.key_type_id, other.key_type_id)\n ...\n >>> component.provideAdapter(DummyKeyReference)\n >>> object1 = MyObject()\n >>> references.add(object1, 2)\n Traceback (most recent call last):\n ...\n TypeError: ('Could not adapt', 2...\n >>> value1 = MyObject()\n >>> value2 = MyObject()\n >>> references.add(object1, value1)\n >>> references.add(object1, value2)\n\nValues can be retrieved by their key:\n\n >>> set(references.get(object1)) == set((value1, value2))\n True\n\nReferences can be removed:\n\n >>> references.remove(object1, value1)\n >>> list(references.get(object1)) == [value2]\n True\n\nBut if the reference is not registered, removing it raises a KeyError.\n\n >>> references.remove(object1, value1)\n Traceback (most recent call last):\n ...\n KeyError:...\n >>> object2 = MyObject()\n >>> references.remove(object2, value2)\n Traceback (most recent call last):\n ...\n KeyError:...\n\nIf you prefer to silently ignore these errors, use `discard`.\n\n >>> references.discard(object1, value1)\n >>> references.discard(object2, value2)\n\nOtherwise, you can use `contains` to determine if the reference exists:\n\n >>> references.contains(object1, value1)\n False\n >>> references.contains(object2, value2)\n False\n >>> references.contains(object1, value2)\n True\n\nIf a key has no associated values, an empty iterable is returned:\n\n >>> references.discard(object1, value2)\n >>> list(references.get(object1))\n []\n\nAdding a value more than once does not cause the value to be included\nin the result sequence more than once:\n\n >>> references.add(object1, value1)\n >>> references.add(object1, value1)\n >>> list(references.get(object1)) == [value1]\n True\n\nThe `set` method destructively sets the given values for the object. Repeated\nobjects are collapsed to a single instance.\n\n >>> references.set(object1, (value2, object2, value2, value2, object2))\n >>> references.contains(object1, value1)\n False\n >>> len(list(references.get(object1)))\n 2\n >>> set(references.get(object1)) == set((value2, object2))\n True\n >>> references.set(object1, ())\n >>> len(list(references.get(object1)))\n 0\n\nThe `update` method adds values to the previous values, non-destructively.\n\n >>> references.add(object1, value1)\n >>> references.update(object1, (value2, object2, value2))\n >>> len(list(references.get(object1)))\n 3\n >>> set(references.get(object1)) == set((value1, value2, object2))\n True\n\n\n=======\nCHANGES\n=======\n\n0.3.0 (2009-08-27)\n------------------\n\n- Fix errors introduced in 0.2.0 refactoring:\n\n 1. Stop referring to extrinsicreference module from ZCML.\n The code is now in ``__init__.py``.\n\n 2. Revert `registerShortcut` and `unregisterShortcut` changes.\n These two functions are handlers in ``track_shortcuts.zcml``.\n\n 3. Add more package infrastructure, such as this file.\n\n\n0.2.0 (2009-08-26)\n------------------\n\n- Refactored an existing stable code.\n- Initial release as an egg.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/zc.extrinsicreference", "keywords": "extrinsic key reference zope zope3", "license": "ZPL 2.1", "maintainer": null, "maintainer_email": null, "name": "zc.extrinsicreference", "package_url": "https://pypi.org/project/zc.extrinsicreference/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/zc.extrinsicreference/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/zc.extrinsicreference" }, "release_url": "https://pypi.org/project/zc.extrinsicreference/0.3.0/", "requires_dist": null, "requires_python": null, "summary": "Extrinsic reference registries", "version": "0.3.0" }, "last_serial": 802174, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "a49b0f7afc9b462083c8fccab51fa942", "sha256": "9f95d9804dabc54ebd1da791b5c5426b8ca6d9a4214e73038c5bae2ed2e901d0" }, "downloads": -1, "filename": "zc.extrinsicreference-0.2.0.tar.gz", "has_sig": false, "md5_digest": "a49b0f7afc9b462083c8fccab51fa942", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4549, "upload_time": "2009-08-26T23:50:56", "url": "https://files.pythonhosted.org/packages/05/4a/5465926bed5bfb24d03960ab2aea0636bbc1e80cf88260046466800a28cc/zc.extrinsicreference-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "04f411a2246e82621f6f655eb3a3994b", "sha256": "9ecccdd1f928a3c14b3fe18b50ba59aecf4fc67fe0ae580970bcac238f6a6cca" }, "downloads": -1, "filename": "zc.extrinsicreference-0.3.0.tar.gz", "has_sig": false, "md5_digest": "04f411a2246e82621f6f655eb3a3994b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6599, "upload_time": "2009-08-27T22:21:13", "url": "https://files.pythonhosted.org/packages/1b/a0/eebd3f076177c8b52389ae6b38d3c65c682e2ba95bb817efc35a9515c513/zc.extrinsicreference-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "04f411a2246e82621f6f655eb3a3994b", "sha256": "9ecccdd1f928a3c14b3fe18b50ba59aecf4fc67fe0ae580970bcac238f6a6cca" }, "downloads": -1, "filename": "zc.extrinsicreference-0.3.0.tar.gz", "has_sig": false, "md5_digest": "04f411a2246e82621f6f655eb3a3994b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6599, "upload_time": "2009-08-27T22:21:13", "url": "https://files.pythonhosted.org/packages/1b/a0/eebd3f076177c8b52389ae6b38d3c65c682e2ba95bb817efc35a9515c513/zc.extrinsicreference-0.3.0.tar.gz" } ] }