{ "info": { "author": "Ritesh Kadmawala", "author_email": "ritesh@loanzen.in", "bugtrack_url": null, "classifiers": [], "description": "Falcon Resource Factory\n~~~~~~~~~~~~~~~~~~~~~~~\n\n|version| |Build Status| |License| |Wheel|\n\nA simple falcon library that allows defining a single resource class to\nhandle requests for a single item as well as multiple items. While\nthough its not purely ``RESTful``, sometimes you require your resource\nto support custom endpoints. The library allows you to define such\ncustom endpoints as well as part of the same single resource class.\n\nInstallation\n^^^^^^^^^^^^\n\nInstall the library using pip, or easy\\_install.\n\n::\n\n $ pip install -U falcon-resource-factory\n\nUsage\n^^^^^\n\nThis library exposes a single class\n``falcon_resource_factory.ResourceFactory`` which is used to add your\nsingle resource class to falcon as shown below.\n\n::\n\n import falcon\n from falcon_resource_factory import ResourceFactory\n\n api = falcon.API()\n\n class Resource(object):\n def on_get(req, res, **kwargs):\n # Return single object\n pass\n \n def on_get_list(req, res, **kwargs):\n # Returns list of objects\n pass\n\n\n resource_factory = ResourceFactory()\n resource_factory.add_routes(app, '/res', Resource())\n\nThe ``ResourceFactory`` instance will create two separate resources\ninternally called ``ResourceDetail`` and ``ResourceList`` for handling\nsingle item and list of items respectively and register them with falcon\nat appropriate routes. The generated resources have appropriate handlers\nfor all http methods supported by your resource which in turn just\nwrappers around your resource handlers.\n\nFor eg for the resource defined above, the generated resources will look\nlike as follows\n\n::\n\n class ResourceDetail(object):\n \n def on_get(req, res, **kwargs):\n resource.on_get(req, res, **kwargs):\n \n class ResourceList(object):\n def on_get(req, res, **kwargs):\n resource.on_get_list(req, res, **kwargs):\n\nCustom Detail Identifier\n''''''''''''''''''''''''\n\n``ResourceFactory`` creates the route for detail resource by appending a\nresource identifier to the passed route. By default detail identifier is\n``id`` but you can change it by passing it to ResourceFactory during\ninitialization\n\n::\n\n resource_factory = ResourceFactory(detail_identifier='uuid')\n\nCustom Method Map\n'''''''''''''''''\n\n``ResourceFactory`` by default maps HTTP methods to handlers in the\nresource by using `` : on_`` for detail resources and\n``: on__list`` for list resources. However both of them\nare configiurable during initialization of ``ResourceFactory``. You can\npass a mapping of HTTP methods to methods of your resources for both\nlist and detail resources.\n\n::\n\n resource_factory = ResourceFactory(list_method_map={\n 'GET': 'on_get_collection',\n 'POST': 'on_post_collection'\n .....\n }, detail_method_map={\n 'GET': 'get_obj',\n 'POST': 'post_obj'\n ....\n })\n\n\n class Resource(object):\n\n def on_get_collection(req, res, **kwargs)\n pass\n\n def on_post_collection(req, res, **kwargs)\n pass\n\n def get_obj(req, res, **kwargs)\n pass\n\n def post_obj(req, res, **kwargs)\n pass\n\nCustomViews\n'''''''''''\n\nSometimes, you want to support api's that are not CRUD. In such\nsituations, purely RESTful approach suggests that you create more\nresources instead of defining custom verbs. However, sometime its easier\nto define custom endpoints/actions instead of mapping them to resources\nwhich might not be that straightforward. ``ResourceFactory`` support\ndefining custom views by automatically creating separate resources for\neach custom view and registering with falcon. You need to pass a list of\nview specs to ``ResourceFactory`` during initialization and it takes\ncare of rest\n\n::\n\n resource_factory = ResourceFactory(custom_views=[\n {\n \"route\": \"/action1/\",\n \"view\": \"action1\",\n \"methods\": ['GET']\n },\n {\n \"route\": \"/action2/\",\n \"view\": \"action2\",\n \"methods\": ['POST']\n }\n ])\n\n\n class Resource(object):\n\n def on_get(req, res, **kwargs):\n pass\n\n def action1(req, res, **kwargs):\n pass\n\n def action2(req, res, **kwargs):\n pass\n \n\n#### Contributing ``falcon-resource-factory`` is distributed under MIT\nLicense.\n\nFork the repository to your own account.\n\nClone the repository to a suitable location on your local machine.\n\n::\n\n $git clone https://github.com/loanzen/falcon-resource-factory.git\n\nTo update the project from within the project's folder you can run the\nfollowing command:\n\n::\n\n $git pull --rebase\n\n##### Building\n\nInstall the project's dependencies.\n\n::\n\n $pip install -r requirements.txt\n $pip install -r requirements-dev.txt\n\n##### Feature Requests\n\nI'm always looking for suggestions to improve this project. If you have\na suggestion for improving an existing feature, or would like to suggest\na completely new feature, please file an issue with my `Github\nrepository `__\n\n##### Bug Reports\n\nYou may file bug reports on `Github\nrepository `__\n\n##### Pull Requests\n\nAlong with my desire to hear your feedback and suggestions, I'm also\ninterested in accepting direct assistance in the form of new code or\ndocumentation. Please feel free to file pull requests against my `Github\nrepository `__\n\n##### Tests\n\nAll pull request should pass the test suite which can launched simply\nwith\n\n::\n\n python setup.py test\n\n.. |version| image:: https://img.shields.io/pypi/v/falcon-resource-factory.svg\n :target: https://pypi.python.org/pypi/falcon-resource-factory/\n.. |Build Status| image:: https://travis-ci.org/loanzen/falcon-resource-factory.svg?branch=master\n :target: https://travis-ci.org/loanzen/falcon-resource-factory\n.. |License| image:: http://img.shields.io/:license-mit-blue.svg\n :target: https://pypi.python.org/pypi/falcon-resource-factory/\n.. |Wheel| image:: https://img.shields.io/pypi/wheel/factory-resource-factory.svg\n :target: https://pypi.python.org/pypi/falcon-resource-factory/\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/loanzen/falcon-resource-factory", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "falcon-resource-factory", "package_url": "https://pypi.org/project/falcon-resource-factory/", "platform": "", "project_url": "https://pypi.org/project/falcon-resource-factory/", "project_urls": { "Homepage": "https://github.com/loanzen/falcon-resource-factory" }, "release_url": "https://pypi.org/project/falcon-resource-factory/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "A simple falcon library that allows defining a single resource class to handle requests for a single item as well as multiple items", "version": "0.0.2" }, "last_serial": 2910668, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "672d177300d7bd64f02f0b268804baf3", "sha256": "fa7452fc437a45c267ed172827741056aba2e6af1d872602cb6f2c5188a351e8" }, "downloads": -1, "filename": "falcon_resource_factory-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "672d177300d7bd64f02f0b268804baf3", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 4870, "upload_time": "2017-05-30T19:25:21", "url": "https://files.pythonhosted.org/packages/59/40/03c90aedf59b89c05e9af9a70b72a0ad66903180d943b0f80e46d8817891/falcon_resource_factory-0.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f226029e9fb60cf7da9403d15cbfe437", "sha256": "46bb7ade37776382feef9083f85c1652779fd806105e0eb102b419c0bf386a2d" }, "downloads": -1, "filename": "falcon-resource-factory-0.0.1.tar.gz", "has_sig": false, "md5_digest": "f226029e9fb60cf7da9403d15cbfe437", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3479, "upload_time": "2017-05-30T19:24:00", "url": "https://files.pythonhosted.org/packages/9b/03/8f55eafa210875f8a0fc9cf9306a487ee9a039b5297e238af2b13e2608f0/falcon-resource-factory-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "8228d1f381785abf8134f27dec01e157", "sha256": "173943f54a3e436ba451cf48764ede4c009961edefa61048cc16109c729ec5b2" }, "downloads": -1, "filename": "falcon_resource_factory-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8228d1f381785abf8134f27dec01e157", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 9071, "upload_time": "2017-05-30T19:44:02", "url": "https://files.pythonhosted.org/packages/09/0c/943356873eb002af6b12bd1e832a0dc76a955540b2665969b82decd78cdb/falcon_resource_factory-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "661583d54c020c1723a0e51b18d7b98b", "sha256": "057651f9c580594365c01b2aef2e4d73bb5b47b49c2fa459e250447fad236c71" }, "downloads": -1, "filename": "falcon-resource-factory-0.0.2.tar.gz", "has_sig": false, "md5_digest": "661583d54c020c1723a0e51b18d7b98b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5566, "upload_time": "2017-05-30T19:43:58", "url": "https://files.pythonhosted.org/packages/99/62/c070b1cc38c3771345d0e516bb2681a6fb8bdc51f5a90ffd28bb7fde904a/falcon-resource-factory-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8228d1f381785abf8134f27dec01e157", "sha256": "173943f54a3e436ba451cf48764ede4c009961edefa61048cc16109c729ec5b2" }, "downloads": -1, "filename": "falcon_resource_factory-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8228d1f381785abf8134f27dec01e157", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 9071, "upload_time": "2017-05-30T19:44:02", "url": "https://files.pythonhosted.org/packages/09/0c/943356873eb002af6b12bd1e832a0dc76a955540b2665969b82decd78cdb/falcon_resource_factory-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "661583d54c020c1723a0e51b18d7b98b", "sha256": "057651f9c580594365c01b2aef2e4d73bb5b47b49c2fa459e250447fad236c71" }, "downloads": -1, "filename": "falcon-resource-factory-0.0.2.tar.gz", "has_sig": false, "md5_digest": "661583d54c020c1723a0e51b18d7b98b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5566, "upload_time": "2017-05-30T19:43:58", "url": "https://files.pythonhosted.org/packages/99/62/c070b1cc38c3771345d0e516bb2681a6fb8bdc51f5a90ffd28bb7fde904a/falcon-resource-factory-0.0.2.tar.gz" } ] }