This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

This package is intended to provide decorators which execute custom actions in case of exceptions. Let’s see an example:

First we need an object with some methods. These methods we decorate with the PrintOnFailure-decorator. This simple example decorator prints a given message in case of an exception.

>>> from failureaction import ConflictError
>>> from failureaction import PrintOnFailure
>>> class TestOb(object):
...    @PrintOnFailure(msg='Some numeric calculation went wrong!')
...    def divide(self, a, b):
...        return a/b
...    @PrintOnFailure()
...    def doraise(self):
...        raise ConflictError

We have two methods. One (divide) does numerical division of two numbers and another raises a custom defined ConflictError. Now let’s see the methods in action:

>>> ob = TestOb()
>>> ob.divide(4, 2)
>>> ob.divide(42, 0)
Some numeric calculation went wrong!
>>> ob.doraise()
Traceback (most recent call last):

The ActionOnFailure decorator provided by the module is intended to be overriden by a custom class. Like this:

>>> from failureaction import ActionOnFailure
>>> class MailOnFailure(ActionOnFailure):
...     def __init__(self, subject):
...         self.subject = subject
...     def _doaction(self, context, e):
...         """ send a mail, if an exception was raised """
...         print "Subject:", self.subject
...         print e
>>> class TestOb2(object):
...     @MailOnFailure(subject='An error occured')
...     def critical(self):
...         import _not_existent_hopefully_
>>> ob2 = TestOb2()
>>> ob2.critical()
Subject: An error occured
No module named _not_existent_hopefully_
Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
failureaction-1.0a1.tar.gz (2.4 kB) Copy SHA256 Checksum SHA256 Source Aug 26, 2010

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting