{ "info": { "author": "Raphael Cohen", "author_email": "raphael.cohen.utt@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries" ], "description": "falcon-sorting-hook\n======================\n\n.. image:: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n :target: LICENSE\n.. image:: https://travis-ci.org/Darkheir/falcon-sorting-hook.svg?branch=master\n :target: https://travis-ci.org/Darkheir/falcon-sorting-hook\n.. image:: https://codecov.io/gh/Darkheir/falcon-sorting-hook/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/Darkheir/falcon-sorting-hook\n.. image:: https://api.codacy.com/project/badge/Grade/a8a34e89d34b4a928e988fe1624e2eae\n :target: https://www.codacy.com/app/Darkheir/falcon-sorting-hook?utm_source=github.com&utm_medium=referral&utm_content=Darkheir/falcon-sorting-hook&utm_campaign=Badge_Grade\n.. image:: https://pyup.io/repos/github/Darkheir/falcon-sorting-hook/shield.svg\n :target: https://pyup.io/repos/github/Darkheir/falcon-sorting-hook/\n :alt: Updates\n\n\nA small falcon hook to parse sorting elements from the request.\n\nUsage\n-----\n\nThe easiest way to use this hook is the following:\n\n.. code:: python\n\n class Resource:\n sorting_fields = (\"foo\", \"bar\") # List of fields allowed for sorting\n\n @falcon.before(SortingHook())\n def on_get(self, req, resp, user):\n # Here req['context']['sort'] is set\n\nThe Hook will look in the query parameters for parameters looking like :code:`sort=value`.\n\nThe default sorting order is ascending.\nTo sort in a descending order a minus (:code:`-`) sign needs to be specified before the value.\ni.e. :code:`sort=-value`\n\nIt is possible to specify multiple sorting values by separating them with a comma.\ni.e. :code:`sort=-value1,value2`\n\nIt will create a list in the request context accessible at :code:`req.context['sort']`.\nThis list consists of tuples where the first element is the name of the field to sort on\nand the second the order to follow (either :code:`ASC` or :code:`DESC`)\n\ni.e. :code:`[('foo', 'ASC'), ('bar', 'DESC')]`.\n\n\nConfiguration options\n---------------------\n\nAllowing fields for sorting\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nFor security reasons, the fields allowed for sorting must be specified in\nthe :code:`sorting_fields` attribute of the resource.\n\nAll the fields not defined in it will be discarded by the hook.\n\n\nDefault sorting order\n~~~~~~~~~~~~~~~~~~~~~\n\nIt is possible to specify a default sorting order by setting the :code:`default_sorting` attribute in the resource.\n\nThis attribute must be a string or a tuple that respects the convention we have for the request parameter.\n\nThe attributes specified as the default order must also be part of :code:`sorting_fields`.\n\nExamples:\n\n.. code:: python\n\n default_sorting = '-foo'\n # or\n default_sorting = ('foo', '-bar')\n\nHook configuration\n~~~~~~~~~~~~~~~~~~\n\nOne parameter can be passed to the hook:\n\n* sort_query_key : The name of the key used in the query to sort data. Default: :code:`sort`.\n\nExample:\n\n.. code:: python\n\n @falcon.before(PaginationFromRequestHook(\n sort_query_key='order',\n ))\n def on_get(self, req, resp, user):\n # Get request\n\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/darkheir/falcon-sorting-hook", "keywords": "falcon sorting sort hook api", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "falcon-sorting", "package_url": "https://pypi.org/project/falcon-sorting/", "platform": "", "project_url": "https://pypi.org/project/falcon-sorting/", "project_urls": { "Homepage": "https://github.com/darkheir/falcon-sorting-hook" }, "release_url": "https://pypi.org/project/falcon-sorting/0.2.0/", "requires_dist": [ "falcon (>=0.3)" ], "requires_python": "", "summary": "Falcon sorting helper", "version": "0.2.0" }, "last_serial": 4795586, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "6df7adcc0ce1ca89c60a41da8a1da1d6", "sha256": "958826c56b93e2e9e4bb42dc94feeb039c2e7130eb25ab57768deec07932a15f" }, "downloads": -1, "filename": "falcon_sorting-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "6df7adcc0ce1ca89c60a41da8a1da1d6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4029, "upload_time": "2019-01-27T22:25:09", "url": "https://files.pythonhosted.org/packages/6a/22/5c486d5677e1ae648a237ca40083ca91b2f1fecdc536d56201e6b9cae9ff/falcon_sorting-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "05f22b8f85555466785bc2833751025e", "sha256": "c7cbff187a429d376c544681d30ecbb8fedf97bb44aa8f3f9de6b6d57bf28922" }, "downloads": -1, "filename": "falcon_sorting-0.0.1.tar.gz", "has_sig": false, "md5_digest": "05f22b8f85555466785bc2833751025e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3046, "upload_time": "2019-01-27T22:25:12", "url": "https://files.pythonhosted.org/packages/4c/e7/115b745fdfc281f6251621fb2db8f16d770fbcec79c0a0713d0ae5446d9b/falcon_sorting-0.0.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "382fa34babd896c19341bafdf571aa50", "sha256": "c781efca49359ca0158d1106ec04198435a85c697b659143f321420eca05212d" }, "downloads": -1, "filename": "falcon_sorting-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "382fa34babd896c19341bafdf571aa50", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4567, "upload_time": "2019-02-08T13:50:58", "url": "https://files.pythonhosted.org/packages/90/bf/af89ac79e42d259fc75e9aa2a7dd4928845ff21098da5e11e895d46dffb3/falcon_sorting-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "20030cfcd4f5325a693ba75a33c14b43", "sha256": "d869fa5c8dfe6d34c694f71ad1116f7155899701ee67b36e9a16a09c49f2b980" }, "downloads": -1, "filename": "falcon_sorting-0.2.0.tar.gz", "has_sig": false, "md5_digest": "20030cfcd4f5325a693ba75a33c14b43", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3710, "upload_time": "2019-02-08T13:50:59", "url": "https://files.pythonhosted.org/packages/63/08/617d5d7eaaedb2fb2e52c3c153ff4714cbfdc8153de89f30b4626c0269c8/falcon_sorting-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "382fa34babd896c19341bafdf571aa50", "sha256": "c781efca49359ca0158d1106ec04198435a85c697b659143f321420eca05212d" }, "downloads": -1, "filename": "falcon_sorting-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "382fa34babd896c19341bafdf571aa50", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4567, "upload_time": "2019-02-08T13:50:58", "url": "https://files.pythonhosted.org/packages/90/bf/af89ac79e42d259fc75e9aa2a7dd4928845ff21098da5e11e895d46dffb3/falcon_sorting-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "20030cfcd4f5325a693ba75a33c14b43", "sha256": "d869fa5c8dfe6d34c694f71ad1116f7155899701ee67b36e9a16a09c49f2b980" }, "downloads": -1, "filename": "falcon_sorting-0.2.0.tar.gz", "has_sig": false, "md5_digest": "20030cfcd4f5325a693ba75a33c14b43", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3710, "upload_time": "2019-02-08T13:50:59", "url": "https://files.pythonhosted.org/packages/63/08/617d5d7eaaedb2fb2e52c3c153ff4714cbfdc8153de89f30b4626c0269c8/falcon_sorting-0.2.0.tar.gz" } ] }