{ "info": { "author": "Shane R. Spencer", "author_email": "shane@bogomip.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 1 - Planning", "Environment :: No Input/Output (Daemon)", "Intended Audience :: Information Technology", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "indicted\n=========\n\nindicted - Indexed Document Class\n\nSummary\n-------\n\nFind an list element, which is a dict, by a keys value\n\nUsage\n-----\n\nTake for example the following data. This structure is being used to reduce \nrelationships between a parent object and sub objects. This allows us to create \nindexes that help with relationships rather than making multiple calls to a \ndatabase. This is just an example structure of a document. This specific \nstructure will benifit heavily from a multi-value index on **subdata._id**.\n\n```javascript\n{\n \"_id\" : ObjectId(\"4f3eb7cac4f804960a859467\"),\n \"subdata\" : [\n {\n \"_id\" : ObjectId(\"4f3eb7cac4f804960a859468\"),\n \"bits\" : 1234\n },\n {\n \"_id\" : ObjectId(\"4f3eb7cac4f804960a859469\"),\n \"bits\" : 5678\n }\n ]\n}\n```\n\nIf we access the **subdata** key in the root of this document we will be given \nan array when using standard Dict/List types.\n\n```python\n[{u'_id': ObjectId('4f3eb7cac4f804960a859468'), u'bits': 1234.0},\n {u'_id': ObjectId('4f3eb7cac4f804960a859469'), u'bits': 5678.0}]\n```\n\nIdeally we would want to return the list element that matches a specific **_id** \nif the list contains dictionaries that have a key matching that ObjectId. This \nis where indicted and Inist comes in. InDict is a simple Dict wrapper \nthat uses InList for all list type values. As InList is initialized and \nmodified it keeps an internal dictionary of **_id** references relating to list \npositions. An extra function called **InList.find** is used to pull out a \nreferenced object if it finds one. **None** is returned otherwise.\n \n```python\nimport pprint\nimport pymongo\n\nfrom bson import ObjectId\n\nfrom indicted import InDict\n\nclass MongoInDict(InDict):\n INDEXCLASS = ObjectId\n INDEXKEY = '_id'\n\nconnection = pymongo.Connection(document_class=MongoInDict)\ndatabase = connection.test\n\ndata = database.data.find_one()\n\npprint.pprint(data['subdata'].find(ObjectId('4f3eb7cac4f804960a859469')))\npprint.pprint(data['subdata'].find(ObjectId('000000000000000000000000')))\n```\n\nYields\n\n```python\n{u'_id': ObjectId('4f3eb7cac4f804960a859469'), u'bits': 5678.0}\nNone\n```\n\nThere is also **indicted.OrderedInDict** that inherits \n**collections.OrderedDict**. This is incredibly useful for maintaining the \ndocument key ordering of your documents.\n\nStatus\n------\n\nCurrently this module only creates references during the initialization of the \nlist. This will be addressed soon.\n \nTodo\n----\n\n* Dot notation\n* JSON encoding/decoding/pretty printing helpers", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/whardier/indicted", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "indicted", "package_url": "https://pypi.org/project/indicted/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/indicted/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/whardier/indicted" }, "release_url": "https://pypi.org/project/indicted/0.0.2/", "requires_dist": null, "requires_python": null, "summary": "Indexed Dictionary Class", "version": "0.0.2" }, "last_serial": 793263, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "dcc26baecb0af92b3e4cdfbdc09b6f1d", "sha256": "bbb87f15281d988423d336d1081e751a47651206b63892f6e9d9c333550ac09a" }, "downloads": -1, "filename": "indicted-0.0.1.tar.gz", "has_sig": false, "md5_digest": "dcc26baecb0af92b3e4cdfbdc09b6f1d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3141, "upload_time": "2012-11-02T21:10:10", "url": "https://files.pythonhosted.org/packages/8d/f3/08462ec4229d649559199cc5f8221d044f7692211ed3e40a4edf227df643/indicted-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "6eb2704564adb2bb6a4a37af7e640977", "sha256": "10a70f885e84d8b1f11dd803e1a1755564722ba44921299cdacdda79ed5b88ea" }, "downloads": -1, "filename": "indicted-0.0.2.tar.gz", "has_sig": false, "md5_digest": "6eb2704564adb2bb6a4a37af7e640977", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3461, "upload_time": "2012-11-02T21:17:23", "url": "https://files.pythonhosted.org/packages/5d/3e/580b84436b17c42cc9119bd30f7c1e6c22158729d94bf93f57c7e747f9c5/indicted-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6eb2704564adb2bb6a4a37af7e640977", "sha256": "10a70f885e84d8b1f11dd803e1a1755564722ba44921299cdacdda79ed5b88ea" }, "downloads": -1, "filename": "indicted-0.0.2.tar.gz", "has_sig": false, "md5_digest": "6eb2704564adb2bb6a4a37af7e640977", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3461, "upload_time": "2012-11-02T21:17:23", "url": "https://files.pythonhosted.org/packages/5d/3e/580b84436b17c42cc9119bd30f7c1e6c22158729d94bf93f57c7e747f9c5/indicted-0.0.2.tar.gz" } ] }