{ "info": { "author": "Tom Gross", "author_email": "itconsense@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Zope Public License", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "====================\nFailureaction Readme\n====================\n\nThis package is intended to provide decorators which execute custom actions\nin case of exceptions. Let's see an example:\n\nFirst we need an object with some methods. These methods we decorate with\nthe *PrintOnFailure*-decorator. This simple example decorator prints a given\nmessage in case of an exception.\n\n >>> from failureaction import ConflictError\n >>> from failureaction import PrintOnFailure\n >>> class TestOb(object):\n ...\n ... @PrintOnFailure(msg='Some numeric calculation went wrong!')\n ... def divide(self, a, b):\n ... return a/b\n ...\n ... @PrintOnFailure()\n ... def doraise(self):\n ... raise ConflictError\n\nWe have two methods. One (divide) does numerical division of two numbers\nand another raises a custom defined ConflictError. Now let's see the methods in\naction:\n\n >>> ob = TestOb()\n >>> ob.divide(4, 2)\n 2\n\n >>> ob.divide(42, 0)\n Some numeric calculation went wrong!\n\n >>> ob.doraise()\n Traceback (most recent call last):\n ...\n ConflictError\n\nThe *ActionOnFailure* decorator provided by the module is intended to be\noverriden by a custom class. Like this:\n\n >>> from failureaction import ActionOnFailure\n >>> class MailOnFailure(ActionOnFailure):\n ...\n ... def __init__(self, subject):\n ... self.subject = subject\n ...\n ... def _doaction(self, context, e):\n ... \"\"\" send a mail, if an exception was raised \"\"\"\n ... print \"Subject:\", self.subject\n ... print e\n\n >>> class TestOb2(object):\n ...\n ... @MailOnFailure(subject='An error occured')\n ... def critical(self):\n ... import _not_existent_hopefully_\n\n >>> ob2 = TestOb2()\n >>> ob2.critical()\n Subject: An error occured\n No module named _not_existent_hopefully_", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": "Exception Decorator Zope", "license": "ZPL 2.1", "maintainer": null, "maintainer_email": null, "name": "failureaction", "package_url": "https://pypi.org/project/failureaction/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/failureaction/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/failureaction/1.0a1/", "requires_dist": null, "requires_python": null, "summary": "Decorators for actions executed in case of an exception", "version": "1.0a1" }, "last_serial": 791871, "releases": { "1.0a1": [ { "comment_text": "", "digests": { "md5": "b91f455cd33f542ec3fc3de0637d5c86", "sha256": "9f2124e2005b2207c53fccae496d733d28531e01920e584e6d7a2c9e2e656551" }, "downloads": -1, "filename": "failureaction-1.0a1.tar.gz", "has_sig": false, "md5_digest": "b91f455cd33f542ec3fc3de0637d5c86", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2355, "upload_time": "2010-08-26T15:18:20", "url": "https://files.pythonhosted.org/packages/db/ee/82e13857d151d2a02ee22c3805e8ae4b6b6f66de91be7dcf2d8c2becef90/failureaction-1.0a1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b91f455cd33f542ec3fc3de0637d5c86", "sha256": "9f2124e2005b2207c53fccae496d733d28531e01920e584e6d7a2c9e2e656551" }, "downloads": -1, "filename": "failureaction-1.0a1.tar.gz", "has_sig": false, "md5_digest": "b91f455cd33f542ec3fc3de0637d5c86", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2355, "upload_time": "2010-08-26T15:18:20", "url": "https://files.pythonhosted.org/packages/db/ee/82e13857d151d2a02ee22c3805e8ae4b6b6f66de91be7dcf2d8c2becef90/failureaction-1.0a1.tar.gz" } ] }