{ "info": { "author": "Jakub Stasiak", "author_email": "jakub@stasiak.at", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries", "Topic :: Utilities" ], "description": "Cask\n====\n\n.. image:: https://travis-ci.org/jstasiak/cask.png?branch=master\n :alt: Build status\n :target: https://travis-ci.org/jstasiak/cask\n\n*Cask* is Injector-enabled, Python application microframework modelled after Flask.\n\nIt's purpose is to make the amount of boilerplate you need to write when developing your application smaller. Here's a simple example:\n\n.. code-block:: python\n\n >>> from cask import Cask\n >>> from injector import inject\n >>>\n >>> def configure(binder):\n ... binder.bind(str, to='ABC')\n ...\n >>> @Cask.run_main(modules=[configure])\n ... @inject(s=str)\n ... def main(s):\n ... print(s)\n ...\n ABC\n\n\n``Cask.run_main`` (it works both as class and instance method, see below) does the ``if __name__ == '__main__'`` check for you. So this\n\n.. code-block:: python\n\n >>> app = Cask()\n >>> @app.run_main\n ... def main():\n ... print(111)\n ...\n 111\n\nis shorter version of\n\n.. code-block:: python\n\n >>> app = Cask()\n >>> @app.main\n ... def main():\n ... print(222)\n ...\n >>> if __name__ == '__main__':\n ... app.run()\n ...\n 222\n\n\nConstruction\n------------\n\n``Cask`` constructor and ``Cask.run_main`` class method accept the following optional keyword arguments:\n\n* ``modules`` - iterable of Injector modules, defaults to empty sequence\n* ``injector``- instance of Injector to configure and use, by default new instance will be created for you\n\nHooks\n-----\n\n``Cask`` instance provides the following decorators allowing you to register hooks (note that you can inject into registered functions):\n\n* ``Cask.before_main`` - should expect no parameters, if non-None value is returned application execution main function won't be executed\n* ``Cask.after_main`` - should expect single ``result`` parameter and return processed result (modified or not)\n* ``Cask.exception_handler(ExceptionCLass)`` - will handle exception raised during the application execution, should expect single argument called ``e`` and containing exception value:\n\n .. code-block:: python\n\n >>> app = Cask()\n >>> @app.exception_handler(Exception)\n ... def handle(e):\n ... print('got exception %s' % (e,))\n ...\n >>> @app.run_main\n ... def main():\n ... raise Exception(123)\n ...\n got exception 123\n\n* ``Cask.main`` - main function should expect no arguments and may return something\n\n\nYou can, of course, register more than one callable for hooks other than ``main``.\n\n.. note:: Only first matching ``exception_handler`` hook will be called, if any.\n\nExecution\n---------\n\nThis is what happens when you run Cask-based application:\n\n#. Injector is configured using provided ``modules``\n#. ``before_main`` hooks are called\n#. If ``before_main`` hooks didn't return value different than None, ``main`` hook is executed\n#. ``after_main`` hooks are called\n\n\nCopyright\n---------\n\nCopyright (C) 2013 Jakub Stasiak\n\nThis source code is licensed under MIT license, see LICENSE file for details.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jstasiak/cask", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "cask", "package_url": "https://pypi.org/project/cask/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/cask/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/jstasiak/cask" }, "release_url": "https://pypi.org/project/cask/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "Injector-enabled Python application microframework", "version": "0.1.1" }, "last_serial": 845398, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "d433d1584190abe59be7a1b2b5046b29", "sha256": "95025a81940d82faa220406f331731bb6f873564d5246ff64c474bfac42fcf7c" }, "downloads": -1, "filename": "cask-0.1.0.tar.gz", "has_sig": false, "md5_digest": "d433d1584190abe59be7a1b2b5046b29", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3564, "upload_time": "2013-08-21T08:25:24", "url": "https://files.pythonhosted.org/packages/38/22/47bc7acefff7dd5e1db2914f3b831d51c70981b2c4f2248ef391cc47a373/cask-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "2cfb27a3bc4f737881770bec89f3f967", "sha256": "4c8bff7957f5393912edf85bb2dcb868baa4e5064be379835e3ad45dd9b26b26" }, "downloads": -1, "filename": "cask-0.1.1.tar.gz", "has_sig": false, "md5_digest": "2cfb27a3bc4f737881770bec89f3f967", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3599, "upload_time": "2013-08-21T21:53:45", "url": "https://files.pythonhosted.org/packages/ba/96/3c431a06ee27017fd440715e7e2b706a091caf0888f2a1cde5b1d08a40e3/cask-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2cfb27a3bc4f737881770bec89f3f967", "sha256": "4c8bff7957f5393912edf85bb2dcb868baa4e5064be379835e3ad45dd9b26b26" }, "downloads": -1, "filename": "cask-0.1.1.tar.gz", "has_sig": false, "md5_digest": "2cfb27a3bc4f737881770bec89f3f967", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3599, "upload_time": "2013-08-21T21:53:45", "url": "https://files.pythonhosted.org/packages/ba/96/3c431a06ee27017fd440715e7e2b706a091caf0888f2a1cde5b1d08a40e3/cask-0.1.1.tar.gz" } ] }