{ "info": { "author": "Dailymotion IT Team", "author_email": "contact@dmcloud.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python", "Topic :: Database" ], "description": "Picomongo\n#########\n\nFaster than minimongo, lighter than micromongo, please welcome picomongo, the ultimate Mongo ODM made by Dailymotion.\n\nGetting started\n===============\n\nTo start off with picomongo, just import it::\n\n >>> from picomongo import Document, ConnectionManager\n >>> ConnectionManager.configure()\n\nAnd you're ready, let's define a document::\n\n >>> class UserDocument(Document):\n ... pass\n >>> user = UserDocument({'name': 'Mike'})\n >>> user\n UserDocument({'name': 'Mike'})\n >>> user.name\n 'Mike'\n >>> user.save()\n\nYOU: Wait, wait where is my document ?\n\nDon't worry, in order to facilitate your work, picomongo use these default values:\n\n* Mongo uri: 'mongodb://localhost'\n* Database: 'test'\n* Collection: Your document class name in lowercase\n\nYou have access to these values, which are traditionnal pymongo objects::\n\n >>> UserDocument.con\n Connection('localhost', 27017)\n >>> UserDocument.db\n Database(Connection('localhost', 27017), u'test')\n >>> UserDocument.col\n Collection(Database(Connection('localhost', 27017), u'test'), u'userdocument')\n\n\nOne thing you should always keep in mind, you always need to call configure before be able to save/retrieve your documents. If you want to use the default configuration, just call configure without arguments otherwise see below (part Configuration time).\n\nTIP: You can call configure after the declaration of your documents BUT before document saving/retrieving.\n\nYou can use them as you will do with traditionnal pymongo objects, for example you can retrieve your user using traditionnal collection::\n\n >>> UserDocument.col.find_one()\n {u'_id': ObjectId('4eb2cae58250f05eb4000000'), u'name': u'Mike'}\n\nYOU: But wait, why I get a dict, I want an object instead.\n\nDon't worry, it's even more simpler::\n\n >>> user2 = UserDocument.find_one()\n UserDocument({u'_id': ObjectId('4eb2cae58250f05eb4000000'), u'name': u'Mike'})\n >>> user2.name\n u'Mike'\n\nBut when this auto-configuration was done? As soon as you try to access them.\n\nConfigure the collection\n========================\n\nYou can configure on which collection your documents will be saved. You can override the collection_name in your custom Document classes if you want to configure it. Example::\n\n >>> class CustomDocument(Document):\n ... collection_name = 'my_custom_collection'\n >>> custom = CustomDocument()\n >>> custom.col\n Collection(Database(Connection('localhost', 27017), u'test'), u'my_custom_collection')\n\nConfiguration time\n==================\n\nOnce you use it a bit, let's see the most powerful part of picomongo, configuration.\n\nAll configurations are stored in ConnectionManager::\n\n >>> from picomongo import Document, ConnectionManager\n\nYou can add your own configuration by calling the configure method with your configuration. The configuration format is::\n\n {'_default_': {'uri': 'default_uri', 'db': 'default_db'},\n 'document_name': {'uri': 'specific_uri', 'db': 'specific_db', 'col': 'default_col'},\n 'document_name2': ...,}\n\nUri must be a valid mongodb connection uri as described in this doc page: http://www.mongodb.org/display/DOCS/Connections\n\nNothing is required in the configuration, and picomongo will use some rules to compute the final configuration:\n\n* In default configuration:\n * If uri is not present, use 'mongodb://localhost'\n * If db is not present, use 'test'\n* In document configuration:\n * If uri is not present, use default uri\n * If db is not present, use default db\n * If col is not preset, use document class name\n\nYou can access configuration using this syntax::\n\n >>> ConnectionManager.get_config('_default_') # Access default configuration\n >>> ConnectionManager.get_config('document') # Access configuration for document named 'document'\n\nHere is some examples of configurations:\n\n* Change default db::\n\n >>> ConnectionManager.configure({'\\_default\\_': {'db': 'other_db'}})\n >>> ConnectionManager.get_config('\\_default\\_').db\n Database(Connection('localhost', 27017), u'other_db')\n\n* Store some documents in another mongodb instance::\n\n >>> ConnectionManager.configure({'document1': {'uri': 'mongodb://127.0.0.1:8000'}})\n >>> ConnectionManager.get_config('_default_').con\n Connection('localhost', 27017)\n >>> ConnectionManager.get_config('document1').con\n Connection('localhost', 8000)\n\nTIP: This last example will surely fail as picomongo try to connect to this uri during configuration (and you probably do not have a mongodb instance running at this uri).", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "picomongo", "package_url": "https://pypi.org/project/picomongo/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/picomongo/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/picomongo/0.6/", "requires_dist": null, "requires_python": null, "summary": "Ultimate MongoDB Object Document Mapper", "version": "0.6" }, "last_serial": 744373, "releases": { "0.6": [ { "comment_text": "", "digests": { "md5": "c2c34d05b0f894873cc77109844a01ac", "sha256": "39c039698a6b95cb7e27e4af506b413f64f546a1cb2945021d1dd5d81635a2c6" }, "downloads": -1, "filename": "picomongo-0.6.tar.gz", "has_sig": false, "md5_digest": "c2c34d05b0f894873cc77109844a01ac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4176, "upload_time": "2012-09-29T12:39:33", "url": "https://files.pythonhosted.org/packages/12/68/d9b3c47c6217c710b5b4f1c1a0f744e06fb85bb4b2feb26ac888fd030dcb/picomongo-0.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c2c34d05b0f894873cc77109844a01ac", "sha256": "39c039698a6b95cb7e27e4af506b413f64f546a1cb2945021d1dd5d81635a2c6" }, "downloads": -1, "filename": "picomongo-0.6.tar.gz", "has_sig": false, "md5_digest": "c2c34d05b0f894873cc77109844a01ac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4176, "upload_time": "2012-09-29T12:39:33", "url": "https://files.pythonhosted.org/packages/12/68/d9b3c47c6217c710b5b4f1c1a0f744e06fb85bb4b2feb26ac888fd030dcb/picomongo-0.6.tar.gz" } ] }