{ "info": { "author": "Felix Bruckmeier", "author_email": "felix.m.bruckmeier@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "NoSQL Rest Preprocessor\r\n=======================\r\n[![Build Status](https://travis-ci.org/felixbr/nosql-rest-preprocessor.svg?branch=master)](https://travis-ci.org/felixbr/nosql-rest-preprocessor)\r\n[![Coverage Status](https://img.shields.io/coveralls/felixbr/nosql-rest-preprocessor.svg)](https://coveralls.io/r/felixbr/nosql-rest-preprocessor)\r\n\r\nA middleware module which solves common problems when building rest-apis with nosql databases.\r\n\r\n### Installation\r\n\r\n```\r\npip install nosql-rest-preprocessor\r\n```\r\n\r\n### Examples\r\n\r\n```python\r\nfrom nosql-rest-preprocessor.models import BaseModel\r\n\r\nclass AddressModel(BaseModel):\r\n required_attributes = {'street', 'city', 'plz'}\r\n \r\n # if you specify optional attributes explicitely, it will \r\n # not allow anything but these and the required ones\r\n optional_attributes = {'location'}\r\n\r\nclass UserModel(BaseModel):\r\n required_attributes = {'firstName', 'lastName', 'email'}\r\n immutable_attributes = {'id'}\r\n private_attributes = {'password', 'salt'}\r\n \r\n # will use AddressModel to validate, merge and prepare the content of the 'address' attribute\r\n sub_models: {\r\n 'address': AddressModel\r\n }\r\n```\r\n\r\n```python\r\nnew_user_from_request = {\r\n \"firstName\": \"Sepp\",\r\n \"lastName\": \"Huber\",\r\n \"email\": \"sepp.huber@fancepants.com\",\r\n \"address\": {\r\n \"street\": \"Bakerstreet 1\",\r\n \"city\": \"London\",\r\n \"plz\": \"12345\"\r\n }\r\n}\r\n\r\n# checks required_attributes and raises ValidationError if something's amiss\r\nUserModel.validate(new_user_from_request)\r\n\r\n```\r\n\r\n```python\r\nuser_obj_from_db = db.fetch_user_by_email(\"sepp.huber@fancepants.com\")\r\n\r\n# strips out any non-public attributes\r\nresponse_obj = UserModel.prepare_response(user_obj_from_db)\r\n\r\nreturn Response(response_obj)\r\n```\r\n\r\n```python\r\nfrom nosql-rest-preprocessor.models import BaseModel\r\nfrom nosql-rest-preprocessor.resolvers import resolve, ResolveWith\r\n\r\nclass AddressModel(BaseModel):\r\n ...\r\n\r\nclass UserModel(BaseModel):\r\n ...\r\n \r\n resolved_attributes = {\r\n 'address' = ResolveWith(lookup_func=SomeDB.find_address_by_key, model=AddressModel)\r\n }\r\n \r\n...\r\n\r\nuser = {\r\n \"name\": \"cookie_m0nster\",\r\n \"address\": \"foreign_key_for_address\"\r\n}\r\n\r\nresolved_obj = resolve(UserModel, user)\r\n# resolved_obj['address'] is now replaced by the dict fetched by SomeDB.find_address_by_key('foreign_key_for_address')\r\n```\r\n\r\n### Running tests\r\n```\r\npip install detox\r\n\r\ndetox\r\n```\r\n", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/felixbr/nosql-rest-preprocessor/tarball/0.3", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/felixbr/nosql-rest-preprocessor/", "keywords": "nosql,rest,web,middleware", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "nosql-rest-preprocessor", "package_url": "https://pypi.org/project/nosql-rest-preprocessor/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/nosql-rest-preprocessor/", "project_urls": { "Download": "https://github.com/felixbr/nosql-rest-preprocessor/tarball/0.3", "Homepage": "https://github.com/felixbr/nosql-rest-preprocessor/" }, "release_url": "https://pypi.org/project/nosql-rest-preprocessor/0.3/", "requires_dist": null, "requires_python": null, "summary": "A middleware module which solves common problems when building rest-apis with nosql databases.", "version": "0.3" }, "last_serial": 1314520, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "53e6a3674f6fe2b208db2bf50302fbfb", "sha256": "d8860fc10aeab1e51a84be3693a8739ce85c91f3a600c2dd24788d231d00e024" }, "downloads": -1, "filename": "nosql-rest-preprocessor-0.1.zip", "has_sig": false, "md5_digest": "53e6a3674f6fe2b208db2bf50302fbfb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3785, "upload_time": "2014-11-18T14:05:25", "url": "https://files.pythonhosted.org/packages/ca/7a/b8d296c6065946ca8301b92cd0cad1e147ceebb26596ef0a7b510b65767b/nosql-rest-preprocessor-0.1.zip" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "b061e562f9e610565edebc9b7e313822", "sha256": "b9ec7b0125ca6b9debd35dfbdd3590871eba32b7b4f7241ba1f3d3879e9ceba7" }, "downloads": -1, "filename": "nosql-rest-preprocessor-0.2.1.zip", "has_sig": false, "md5_digest": "b061e562f9e610565edebc9b7e313822", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4036, "upload_time": "2014-11-19T23:06:40", "url": "https://files.pythonhosted.org/packages/9e/35/aaf89466ee333120386ea8073b82090d3e91ca26b77a8e1b27f3d0057cfd/nosql-rest-preprocessor-0.2.1.zip" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "a037621fd0b6e854eafdc4cfee7a36c1", "sha256": "f6c5d11df70d0dee96a156c68559e4c6e7c07714ca4fefae9267cffb1cdc5417" }, "downloads": -1, "filename": "nosql-rest-preprocessor-0.3.zip", "has_sig": false, "md5_digest": "a037621fd0b6e854eafdc4cfee7a36c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8376, "upload_time": "2014-11-20T15:30:21", "url": "https://files.pythonhosted.org/packages/2f/d0/814d1e61464b32c3cb0c8b34c87baedfd0e83c3083050cc521507b72c0cd/nosql-rest-preprocessor-0.3.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a037621fd0b6e854eafdc4cfee7a36c1", "sha256": "f6c5d11df70d0dee96a156c68559e4c6e7c07714ca4fefae9267cffb1cdc5417" }, "downloads": -1, "filename": "nosql-rest-preprocessor-0.3.zip", "has_sig": false, "md5_digest": "a037621fd0b6e854eafdc4cfee7a36c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8376, "upload_time": "2014-11-20T15:30:21", "url": "https://files.pythonhosted.org/packages/2f/d0/814d1e61464b32c3cb0c8b34c87baedfd0e83c3083050cc521507b72c0cd/nosql-rest-preprocessor-0.3.zip" } ] }