{ "info": { "author": "Robert Spychala", "author_email": "robspychala@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Database :: Database Engines/Servers", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# simpledict\n\nMakes dict modeling easy for document based databases with minimal extra funcitonality\n\n* Permissioning\n* Embedded documents\n* Minimization of field names\n* Python Properties\n* One python file\n* Doctests - functionality is unit tested\n\nMissing features\n\n* No type system\n* No validation - up to you as the developer to add it.\n\nOther libraries that provide this functionality and more in python\n\n* [@j2lab's](http://twitter.com/j2labs) [DictShield](../../j2labs/DictShield) - great library with a type system and more\n\n# Installation\n\nEasiest way to install is from PyPI\n\n```pip install simpledict```\n\n# Example\n\nCreating a simple model would involve creating a Class that subclasses simpledict.Dictionary\n\n```python\nimport simpledict\n\nclass Tweet(simpledict.Dictionary):\n field_user = \"u\"\n field_text = \"t\"\n field_count = \"c\"\n @property\n def character_count():\n return len(self.text)\n```\n\nand then to create the object:\n\n```python\ntweet = Tweet(user=\"robspychala\", text=\"hey everyone, what's cookin'?\")\n```\n\nand to serialize to a dictionary\n\n```python\ntweet_data = tweet.to_dict()\n```\n\nand of course to de-serialize back to an object, you'd\n\n```python\ntweet = Tweet(**tweet_data)\n```\n\n## Minimization\n\nIf you would like to minimize the field names to what is defined in the field_* values you pass in a minimize=True value to the to_dict() method\n\n```python\nminimized_tweet_data = tweet.to_dict(minimize=True)\n```\n \nand even if you have minimized data, you'd still be able to de-serialize it to a dictionary, ex:\n\n```python\nminimized_tweet = Tweet(**minimized_tweet_data)\n\nassert(tweet.title == minimized_tweet.title, tweet.user == minimized_tweet.user)\n```\n\n## Properties\n\nIf you would like to serialize properties\n\n```python\ntweet_data_props = tweet.to_dict(properties={\"count\":None})\n\nassert(tweet_data_props[\"count\"] == tweet.count)\n```\n \n## Permissioning\n\nAnd if you don't want to show the user, for whatever reason you'd use the omit_fields option\n\n```python\ntweet_data = tweet.to_dict(omit_fields={\"user\":None})\n\nassert(not tweet_data.has_key(\"user\"))\n```\n\n### Embedded Documents\n\n```python\nimport simpledict\n\nclass UserSettings(Dictionary):\n field_color = \"c\"\n field_size = \"s\"\n \nclass User(Dictionary):\n field_settings = (\"s\", UserSettings)\n field_name = \"n\"\n\nuser = User(name=\"Price\", settings=UserSettings(color=\"purple\", size=\"medium\"))\n```\n\n### array of Embedded Documents\n\n```python\nimport simpledict\n\nclass EmbeddedInnerTest(simpledict.Dictionary):\n field_title = \"t\"\n field_page = \"p\"\n \nclass EmbeddedTest(simpledict.Dictionary):\n field_title = \"t\"\n field_author = \"a\"\n field_toc = (\"o\", list, EmbeddedInnerTest)\n \nembedded_data = { 'title': \"Embedded Title\", 'author': \"Embedded Author\", \n 'toc': [{'t':'Chapter One', 'p': 100}, {'t':'Chapter Two', 'p': 201}]}\nembedded_obj = EmbeddedTest(**embedded_data)\nembedded_obj.title\nembedded_obj.author\nembedded_obj.toc[0].title\nembedded_obj.toc[1].title\nembedded_obj.toc[1].page\n```\n\n\n### MongoDB example\n\n```python\nimport simpledict\nimport pymongo\n\nfrom pymongo import Connection\nconnection = Connection()\ndb = connection.main_database\n\nclass User(simpledict.Dictionary):\n\n field_email = \"e\"\n field_password = \"p\"\n\n def insert(self):\n if not db or not self.email or not self.password:\n raise Exception()\n db[self.__class__.__name__.lower()].insert(self.to_dict(minimize=True))\n return self\n```\n\nand then to use this User class in your app and insert into a mongodb, it would involve\n\n```python\nentry = model.User(email=\"robspychala@gmail.com\",\n password=\"mysekr3t\").insert()\nentry_dict = entry.to_dict(minimize=False)\nself.response.out.write(json.dumps({'success': True, 'result': entry_dict}, \n default=simpledict.json_date_handler))\n```\n\n\n# License\n\nThe simpledict component is released under the MIT License.\n\nThe MIT License (MIT) Copyright (c) 2012 Robert Spychala\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", "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/robspychala/simpledict", "keywords": "dict,mongo", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "simpledict", "package_url": "https://pypi.org/project/simpledict/", "platform": "any", "project_url": "https://pypi.org/project/simpledict/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/robspychala/simpledict" }, "release_url": "https://pypi.org/project/simpledict/0.2.6/", "requires_dist": null, "requires_python": null, "summary": "Simple dictionary wrapper", "version": "0.2.6" }, "last_serial": 799570, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "357d817bed44dcdea89284bfeaf6d709", "sha256": "02d868d405f0c2863b8ae0615df5dfb85dc99b31c93f64a3652cd46c632f4175" }, "downloads": -1, "filename": "simpledict-0.1.tar.gz", "has_sig": false, "md5_digest": "357d817bed44dcdea89284bfeaf6d709", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3902, "upload_time": "2012-02-28T17:17:13", "url": "https://files.pythonhosted.org/packages/42/01/76e56e9fd7955788d8f64901e7075963fe880648a9685f40bd32d3bed674/simpledict-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "0b1c3cd452e72455ab1ae5c60688b0e1", "sha256": "edd7c17c0065f36e98066b10655ff9f82a38e58d498adae32b2ae622343742a3" }, "downloads": -1, "filename": "simpledict-0.1.1.tar.gz", "has_sig": false, "md5_digest": "0b1c3cd452e72455ab1ae5c60688b0e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4018, "upload_time": "2012-02-28T17:32:54", "url": "https://files.pythonhosted.org/packages/3d/8a/ba125e849f58eae643a664e109e2f99a432a658fe6096eebdd7b00a6c922/simpledict-0.1.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "ae949b76f51d32a8f4eeb754df33b984", "sha256": "08cfb4e089a2d0ce4ffe381021678194a53ee0144db0007a416568f585804e7f" }, "downloads": -1, "filename": "simpledict-0.2.tar.gz", "has_sig": false, "md5_digest": "ae949b76f51d32a8f4eeb754df33b984", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4289, "upload_time": "2012-02-29T19:55:07", "url": "https://files.pythonhosted.org/packages/95/da/7fc6a1d467f65111c1dee7028482c231e77886068f0eb741e28ae7b2cd51/simpledict-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "0077843bf9820206a8b2fdf9aa0d7e05", "sha256": "cf6dd616d0919ffa5a195e21460f2d17b7e293ab77e6574eaaf25ef3d5cf4741" }, "downloads": -1, "filename": "simpledict-0.2.1.tar.gz", "has_sig": false, "md5_digest": "0077843bf9820206a8b2fdf9aa0d7e05", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6528, "upload_time": "2012-03-19T17:03:09", "url": "https://files.pythonhosted.org/packages/7b/d6/3586109e074bc89f18aff9769ed674661a89a58ddd1f8cbe0962b7748906/simpledict-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "a75f92c5d8f05d70eb06b304a12c59d7", "sha256": "1dfb2d0bd7a8c40ca5a9eace0ca31c374a609fa49dec076db60f50903a7f0299" }, "downloads": -1, "filename": "simpledict-0.2.2.tar.gz", "has_sig": false, "md5_digest": "a75f92c5d8f05d70eb06b304a12c59d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6927, "upload_time": "2012-03-19T17:07:16", "url": "https://files.pythonhosted.org/packages/fd/7c/335e330eb8d8b82c56c5286b17d5edf6a424ce7187b376d42a371037d373/simpledict-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "559d029b0202e7ba03cdf8476a772994", "sha256": "85b1af8fb987c644d5df776ced8a1d606b781c1cc79e6dd5eed6ef23656790cd" }, "downloads": -1, "filename": "simpledict-0.2.3.tar.gz", "has_sig": false, "md5_digest": "559d029b0202e7ba03cdf8476a772994", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6924, "upload_time": "2012-03-19T17:08:43", "url": "https://files.pythonhosted.org/packages/bf/a0/2657d41eaf8b63b5c10ebbd047f8ad7a66ca2d099df51bbac183c08c7b0a/simpledict-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "93b2044b7be94d146f8bcb3bfeb45610", "sha256": "6a38967a5ec679ad868be012ddc1bed830f1d0501b3b075bf36b89459c9f6380" }, "downloads": -1, "filename": "simpledict-0.2.4.tar.gz", "has_sig": false, "md5_digest": "93b2044b7be94d146f8bcb3bfeb45610", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6933, "upload_time": "2012-04-16T21:27:07", "url": "https://files.pythonhosted.org/packages/ec/9c/35a999215961f4184f37c33f7bd685c800d1c79de14ed8fae5992d1aa05f/simpledict-0.2.4.tar.gz" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "8ab44e3884fcf01c2dacb9a3bfde7a4e", "sha256": "131323f49e0df54f6bbf5e88a039f4846288b48a886c7eb3ff3380be1f308d61" }, "downloads": -1, "filename": "simpledict-0.2.5.tar.gz", "has_sig": false, "md5_digest": "8ab44e3884fcf01c2dacb9a3bfde7a4e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6941, "upload_time": "2012-04-16T22:49:28", "url": "https://files.pythonhosted.org/packages/9c/89/24aaa844ba1a198172802903444da357e2a7f6f4a35a9b9c207af8afb449/simpledict-0.2.5.tar.gz" } ], "0.2.6": [ { "comment_text": "", "digests": { "md5": "693086b70630f36b1edae5c00e872618", "sha256": "9a0a44e31cceb5eff3d79eb486dd89a96177a9d93a93d767491b6008590b9186" }, "downloads": -1, "filename": "simpledict-0.2.6.tar.gz", "has_sig": false, "md5_digest": "693086b70630f36b1edae5c00e872618", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6986, "upload_time": "2012-04-23T22:29:03", "url": "https://files.pythonhosted.org/packages/70/9d/609781073031672f1cfc14797ef6c9540c2ddbf3ccecd43d86732f1611f7/simpledict-0.2.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "693086b70630f36b1edae5c00e872618", "sha256": "9a0a44e31cceb5eff3d79eb486dd89a96177a9d93a93d767491b6008590b9186" }, "downloads": -1, "filename": "simpledict-0.2.6.tar.gz", "has_sig": false, "md5_digest": "693086b70630f36b1edae5c00e872618", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6986, "upload_time": "2012-04-23T22:29:03", "url": "https://files.pythonhosted.org/packages/70/9d/609781073031672f1cfc14797ef6c9540c2ddbf3ccecd43d86732f1611f7/simpledict-0.2.6.tar.gz" } ] }