{ "info": { "author": "Matt Jordan", "author_email": "mattjordan.mail@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Build Tools" ], "description": "# Mongodec\n\n# Overview\nMongodec provides a generalizable wrapper class that can be extended to any python class and allows for easy overwrites and wrapping of methods. In this repo this has been used to implement an extension of `Pymongo` objects which covers a common use case of wishing to apply a filter to all database accesses.\n\n# Setup\nThe easiest way to install Mongodec would be to use pip: `pip install mongodec`. Though this repo can be cloned and you can build from source if you like.\n\n# Example Usage\nIn this section, I'll briefly provide an example for how to use the `FilterMongo*` clasess to automatically apply filters to mongo queries.\n## Connecting to Mongo\nIt is recommended that frequent accesses to mongo databases do so through the provided `MongoConfig` classes\n```\nfrom mongodec import MongoConfig\nimport pymongo # just used for the assert\nconfig = MongoConfig(user='dev',\n password='foobar',\n host='some-host-example.mongodb.net',\n database='dbname',\n port=27017)\nmongo_db_obj = config.db()\nassert isinstance(mongo_db_obj, pymongo.database.Database)\n```\n## Building a filtered database\nAll classes that extend Changeling take an instance of the object they're replicating as the instantiating argument, with potentially other arguments. Suppose we want to look at documents matching the filter `{'name': 'foobar', 'value': {'$gt': 10}}`. Then we can take a pymongo database object and build the filtered database:\n```\nfrom mongodec import FilterMongoDB\nmongo_db = ... #Some instance of pymongo.database.Database\nq_filter = {'name': 'foo', 'value': {'$gt': 10}}\nfilter_mongo_obj = FilterMongoDB(mongo_db, q_filter)\n\n# Examples -- insert some dummy data using pymongo's classes\nreal_collection = mongo_db.collection_name\nreal_collection.insert([{'name': 'foo', 'value': 4},\n {'name': 'foo', 'value': 12},\n {'name': 'bar', 'value': 100}])\n\n# access the collection\nfilter_collection = filter_mongo_obj['collection_name']\nfilter_collection_2 = filter_mongo_obj.collection_name\nfilter_collection_3 = filter_mongo_obj.get_collection('collection_name')\nassert filter_collection == filter_collection_2\nassert filter_collection == filter_collection_3\n\n# operate as if filter_collection were a real collection\nassert filter_collection.count() == 1\nassert (filter_collection.find_one({}, {'_id': 0}}) ==\n {'name': 'foo', 'value': 12})\nfilter_collection.delete_many()\nassert real_collection.count() == 2\nassert filter_collection.count() == 0\n\n# can turn off the filter with the 'no_changeling' kwarg\nassert filter_collection.count(no_changeling=True) == 2\n```\nAll applicable methods are wrapped appropriately, and we offer support for BulkOperations as well.\n\n# Extending your own Changeling classes\nI'll attach some brief documentation about how the `Changeling` class works, but more info is contained in mongodec/changeling.py and one can view the implementation of the `FilterMongo*` classes in mongodec/filter_mongo.py\n\nAny class C that extends Changeling should be viewed as a wrapper for another class B. Any instance of C should then take an instance of B as an instantiating argument. The instance of B inside C is known as the 'base object' and accessible through `C_instance.base_object`.\n\nInternally, each Changeling object keeps track of the wrapping methods with its property `cdict`. To wrap the `funky` method of class `Down2Get`, with the method `ultraFunky` then the `cdict` should look like this:\n```\n{'Down2Get_methods': {'funky': ultraFunky}}\n```\n\nIf we want to wrap _every_ method of `Down2Get` with a method, say, `andTurnt`, the cdict will look like\n```\n{\n'Down2Get_methods': {'funky': ultraFunky},\n'Down2Get_wrap_all': andTurnt\n}\n```\n\nAny method that is tricky to wrap and should be overwritten directly can be done in class definition of `C`.\n\nEach wrapper method takes 3 arguments: func, cdict, and callargs.\nfunc is the function that is being wrapped. cdict is the cdict of the changeling instance, and callargs is a dictionary with _all_ arguments that func takes explicitly named.\n\n## Examples to help you with your own extensions\nA simple extension that demonstrates wrapping of individual methods and all methods is the test method 'test_changeling' in mongodec/tests/test_changeling.py\n\nA simple extension that demonstrates how to overwrite the methods of the base object is the `FilterMongoBulkOperationBuilder` located in mongodec/filter_mongo.py\n\nA more complicated example that encapsulates all the features of `Changeling` is the `FilterMongoCollection` class in mongodec/filter_mongo.py\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/revbucket/mongodec", "keywords": "wrapper mongo filter", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "mongodec", "package_url": "https://pypi.org/project/mongodec/", "platform": "", "project_url": "https://pypi.org/project/mongodec/", "project_urls": { "Homepage": "https://github.com/revbucket/mongodec" }, "release_url": "https://pypi.org/project/mongodec/1.0.16/", "requires_dist": [ "pymongo", "check-manifest; extra == 'dev'", "coverage; extra == 'test'" ], "requires_python": "", "summary": "Wrapper classes with an application for Mongo", "version": "1.0.16" }, "last_serial": 2523722, "releases": { "1.0.11": [ { "comment_text": "", "digests": { "md5": "da978602ddfe0d9c47d950124121f66c", "sha256": "15d7fd59ce1f21c32f0af958d3da2e2b33089a5d23f87657ee4aee8229442569" }, "downloads": -1, "filename": "mongodec-1.0.11.tar.gz", "has_sig": false, "md5_digest": "da978602ddfe0d9c47d950124121f66c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11587, "upload_time": "2016-11-08T20:20:14", "url": "https://files.pythonhosted.org/packages/08/6d/732f4f20c899e35a09de479ae51d7a5b55ef4c12766c8e9d82abc36a6013/mongodec-1.0.11.tar.gz" } ], "1.0.12": [ { "comment_text": "", "digests": { "md5": "016cba66ed8210e9fa48b134714f93b0", "sha256": "38a8162f4ff92de1d4cdd1e3e6568cf9dcba7f45d8011b1682459d77f272f129" }, "downloads": -1, "filename": "mongodec-1.0.12-py2-none-any.whl", "has_sig": false, "md5_digest": "016cba66ed8210e9fa48b134714f93b0", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 15808, "upload_time": "2016-11-08T20:28:27", "url": "https://files.pythonhosted.org/packages/c9/10/5b61aa34fa03e16cea8f97f8be0d6c1004084a9dabd50f68470d913c884a/mongodec-1.0.12-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e7e53d94ffd11372c5e3d877cdc050cd", "sha256": "b8b83be98465e4f30fad3670248d3048a59f824efc293f766cfd8bcaae4c3de1" }, "downloads": -1, "filename": "mongodec-1.0.12-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e7e53d94ffd11372c5e3d877cdc050cd", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 15810, "upload_time": "2016-11-08T20:28:29", "url": "https://files.pythonhosted.org/packages/f6/2d/fc429beb0f364257c50c70ed4167604ca805535f602cf55505ea081b4993/mongodec-1.0.12-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cbc646b933207367df9b662e1affa196", "sha256": "52c116ed563a2580917610959e67f1a70e6e077e7cea57f1da974c12c166f952" }, "downloads": -1, "filename": "mongodec-1.0.12.tar.gz", "has_sig": false, "md5_digest": "cbc646b933207367df9b662e1affa196", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11587, "upload_time": "2016-11-08T20:28:32", "url": "https://files.pythonhosted.org/packages/2e/2f/5b9e0b233f334732af0bbff0b411b0db663f76c26c3a79e17d9fbb14b6ef/mongodec-1.0.12.tar.gz" } ], "1.0.14": [ { "comment_text": "", "digests": { "md5": "968e3903de92b90dc1d601c7f77652fe", "sha256": "0a0369c05869dfe3e7de1122cccc9bc0090bb56d5f63959b2d0b552dee97c14e" }, "downloads": -1, "filename": "mongodec-1.0.14-py2-none-any.whl", "has_sig": false, "md5_digest": "968e3903de92b90dc1d601c7f77652fe", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 15814, "upload_time": "2016-12-15T16:42:10", "url": "https://files.pythonhosted.org/packages/7d/1d/279de6b39c2d3fb16d923ab164a255e7c7747fce620f3f5278739aab71d4/mongodec-1.0.14-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9cc1cc2e041c71440b52587869b85dbd", "sha256": "2e4d986bddeaf6887aea71208005c825e9031452b9d81337b6952700424dc76f" }, "downloads": -1, "filename": "mongodec-1.0.14.tar.gz", "has_sig": false, "md5_digest": "9cc1cc2e041c71440b52587869b85dbd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11597, "upload_time": "2016-12-15T16:42:12", "url": "https://files.pythonhosted.org/packages/a1/00/06ad93f9649bcee0638814291302d9cebe1adc0f1f7fa0671c72cbc286e5/mongodec-1.0.14.tar.gz" } ], "1.0.15": [ { "comment_text": "", "digests": { "md5": "308b5127309c94b1778a1465ed22fbea", "sha256": "969d78b0bfbbbabd218ea28a4224e12277f43e7a85071b72d47eccd03d3a5df7" }, "downloads": -1, "filename": "mongodec-1.0.15-py2-none-any.whl", "has_sig": false, "md5_digest": "308b5127309c94b1778a1465ed22fbea", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 15830, "upload_time": "2016-12-16T18:47:19", "url": "https://files.pythonhosted.org/packages/7b/2e/9879f3467c119636a5da230a9098a3aa8105922f8728c3099fd773cf590d/mongodec-1.0.15-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e8e48d09db8c87a9f50fee33971df11f", "sha256": "f303a2d5fd0d4f70028f22c091ac27d4edd606b18fd1a95ba2fb0020eaad4961" }, "downloads": -1, "filename": "mongodec-1.0.15.tar.gz", "has_sig": false, "md5_digest": "e8e48d09db8c87a9f50fee33971df11f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11610, "upload_time": "2016-12-16T18:47:20", "url": "https://files.pythonhosted.org/packages/01/6f/33e4c6f5d8fa8f64184fca42c09e116bea2861284494cfe7e5f021682a2f/mongodec-1.0.15.tar.gz" } ], "1.0.16": [ { "comment_text": "", "digests": { "md5": "9ff4fdfcc18542d934df32c330c0aa5a", "sha256": "6b30b7f633b71318360fa7aa07b09807b06fdefe8c7cc8f1cd6ceaf0d6408f7f" }, "downloads": -1, "filename": "mongodec-1.0.16-py2-none-any.whl", "has_sig": false, "md5_digest": "9ff4fdfcc18542d934df32c330c0aa5a", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 15996, "upload_time": "2016-12-16T19:30:29", "url": "https://files.pythonhosted.org/packages/f7/fe/85de17baccd0a9fd9ab04697b10f41bc65e9a47129ab4fd0e92a03ccd8ae/mongodec-1.0.16-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "db470255ec3f50640e7e2f1d2cdb7135", "sha256": "dcecce8a13fbc8f028c45b21ab1933ff7b48e56d0da71744d80e6cfc28879f92" }, "downloads": -1, "filename": "mongodec-1.0.16.tar.gz", "has_sig": false, "md5_digest": "db470255ec3f50640e7e2f1d2cdb7135", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11828, "upload_time": "2016-12-16T19:30:30", "url": "https://files.pythonhosted.org/packages/b2/53/8ce36b7664aafeeec9ee1fe603d038eb315eb81db1566ebc5e01382d2025/mongodec-1.0.16.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "6e825ef3c00e8a48150080fd05d47e95", "sha256": "1a97ddd9479d6e8bb5788adb3a3454ec49cbdbc7f01a665d8e7760004d2ece77" }, "downloads": -1, "filename": "mongodec-1.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6e825ef3c00e8a48150080fd05d47e95", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 15631, "upload_time": "2016-10-03T21:20:08", "url": "https://files.pythonhosted.org/packages/82/fb/d4df1b11d3db262d03e37beb4646d3da55b84b4f94ce0c8142d7ce26401d/mongodec-1.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6001f6c0c666b17ad1b9bfefc5cefeb3", "sha256": "0e34ee453fb6d27389828f0041b0d8b81c638f1b3c4d8d7272556d9535e76b33" }, "downloads": -1, "filename": "mongodec-1.0.3.tar.gz", "has_sig": false, "md5_digest": "6001f6c0c666b17ad1b9bfefc5cefeb3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11437, "upload_time": "2016-10-03T21:16:12", "url": "https://files.pythonhosted.org/packages/f2/b3/a63cf84ff1a3f174ccc5604f1cfb79bd9f6b562f6dd610040e7b2c39cdb9/mongodec-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "a5ae1520ad223fb5ffa598e3de897b23", "sha256": "50277f8e204e932bfdd02e8fe29504fc4f3fa5491f90ec6f3657c1fae1faab6c" }, "downloads": -1, "filename": "mongodec-1.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a5ae1520ad223fb5ffa598e3de897b23", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 15628, "upload_time": "2016-10-03T21:20:12", "url": "https://files.pythonhosted.org/packages/b8/e2/9b43c05993b68717b4bbac087efebc8c2fbce1fd4b6b2c5114a05f984189/mongodec-1.0.4-py2.py3-none-any.whl" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "d8e867116935993763bd3579f96ca600", "sha256": "d0bc8088240423d1f19958b98776dd34bd31412ec5f24ac51bf32e70c6c2cd56" }, "downloads": -1, "filename": "mongodec-1.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d8e867116935993763bd3579f96ca600", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 15639, "upload_time": "2016-10-04T15:46:13", "url": "https://files.pythonhosted.org/packages/77/04/4fb935101ab61f0704cf1dcc605428920d5d046df141789e73796e650bed/mongodec-1.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cf6a65702f9b2dabf2a3ee6d36eb3aae", "sha256": "b54c89c23e0f6eaf813e2fd7f837541b4c49eccb12bf496c028946495fc3e594" }, "downloads": -1, "filename": "mongodec-1.0.5.tar.gz", "has_sig": false, "md5_digest": "cf6a65702f9b2dabf2a3ee6d36eb3aae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11442, "upload_time": "2016-10-04T15:46:16", "url": "https://files.pythonhosted.org/packages/e1/08/285b91c9669a9eefb4adc5537fa026fe51f6a97a32ee2bab282e11fea69b/mongodec-1.0.5.tar.gz" } ], "1.0.6": [ { "comment_text": "", "digests": { "md5": "0458628f19133712e7b5dc47903ae5b1", "sha256": "12cd14012386665ae0fa6b127c4723d90a7cfe665813163522e97c4fbcb0f7b3" }, "downloads": -1, "filename": "mongodec-1.0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0458628f19133712e7b5dc47903ae5b1", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 15652, "upload_time": "2016-10-04T15:58:11", "url": "https://files.pythonhosted.org/packages/47/24/1681873582dbcbc155a2fac54b38f805380a2b7d79402c8c8af4d936b3ba/mongodec-1.0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "274f7cd4abbc0e7c4c04ac7e34232b7d", "sha256": "41e27eb768eaa7d2bc066505d4836658bd23f1779504045ad1c97ee96eb9240f" }, "downloads": -1, "filename": "mongodec-1.0.6.tar.gz", "has_sig": false, "md5_digest": "274f7cd4abbc0e7c4c04ac7e34232b7d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11455, "upload_time": "2016-10-04T15:58:13", "url": "https://files.pythonhosted.org/packages/13/f8/7cdeee67756885b245bc6286d6eaca40785a6fb9067a5345fc1eafbf741d/mongodec-1.0.6.tar.gz" } ], "1.0.7": [ { "comment_text": "", "digests": { "md5": "9717361e32ffa12e1d6e13b2a68fda06", "sha256": "cc7d9d9f289e18afd3c0504895c349aa7aacbaf9db6385a5e880ca9dcc25e3a4" }, "downloads": -1, "filename": "mongodec-1.0.7-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9717361e32ffa12e1d6e13b2a68fda06", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 15654, "upload_time": "2016-10-04T16:01:07", "url": "https://files.pythonhosted.org/packages/d7/ff/1c11a6a414e3635a676e90c5715465c05f2a4bd0842608f7b4b245331b45/mongodec-1.0.7-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "02f96376513180bd248e0b220b2a109b", "sha256": "ac5d5f49e5a6a287a97320e036d2c6cf45455ad2e42b94b9103dfed799a143fe" }, "downloads": -1, "filename": "mongodec-1.0.7.tar.gz", "has_sig": false, "md5_digest": "02f96376513180bd248e0b220b2a109b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11455, "upload_time": "2016-10-04T16:01:16", "url": "https://files.pythonhosted.org/packages/ed/f1/88f921ed9427a7b6f28674aca819c62993a88938689be0b3354d371faf6a/mongodec-1.0.7.tar.gz" } ], "1.0.8": [ { "comment_text": "", "digests": { "md5": "ec4c278b37c46398ac36ff41bce539fa", "sha256": "f918d1aedcdf55df98f8f5e3a5d5a2b45e83ca67f1b6cc40003df09b39252dd4" }, "downloads": -1, "filename": "mongodec-1.0.8-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ec4c278b37c46398ac36ff41bce539fa", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 15663, "upload_time": "2016-10-04T16:26:11", "url": "https://files.pythonhosted.org/packages/60/79/662f7edaa95a9bf6f6985ae9edb2d3e302f5b479ffb9614a05ed696a4539/mongodec-1.0.8-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a1c97e587b4a71232f86fc58bbd72c27", "sha256": "30e5728df77cfc8631a1196eb4187220e72473e737f5363853ba12d522a6ef6c" }, "downloads": -1, "filename": "mongodec-1.0.8.tar.gz", "has_sig": false, "md5_digest": "a1c97e587b4a71232f86fc58bbd72c27", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11463, "upload_time": "2016-10-04T16:26:16", "url": "https://files.pythonhosted.org/packages/ef/66/89c97d5e3157bf821cf188a43d7aa2bf976f03721ebe128d1bfc27890438/mongodec-1.0.8.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9ff4fdfcc18542d934df32c330c0aa5a", "sha256": "6b30b7f633b71318360fa7aa07b09807b06fdefe8c7cc8f1cd6ceaf0d6408f7f" }, "downloads": -1, "filename": "mongodec-1.0.16-py2-none-any.whl", "has_sig": false, "md5_digest": "9ff4fdfcc18542d934df32c330c0aa5a", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 15996, "upload_time": "2016-12-16T19:30:29", "url": "https://files.pythonhosted.org/packages/f7/fe/85de17baccd0a9fd9ab04697b10f41bc65e9a47129ab4fd0e92a03ccd8ae/mongodec-1.0.16-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "db470255ec3f50640e7e2f1d2cdb7135", "sha256": "dcecce8a13fbc8f028c45b21ab1933ff7b48e56d0da71744d80e6cfc28879f92" }, "downloads": -1, "filename": "mongodec-1.0.16.tar.gz", "has_sig": false, "md5_digest": "db470255ec3f50640e7e2f1d2cdb7135", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11828, "upload_time": "2016-12-16T19:30:30", "url": "https://files.pythonhosted.org/packages/b2/53/8ce36b7664aafeeec9ee1fe603d038eb315eb81db1566ebc5e01382d2025/mongodec-1.0.16.tar.gz" } ] }