Skip to main content

.. image:: https://travis-ci.org/CloudVE/pyeventsystem.svg?branch=master :target: https://travis-ci.org/CloudVE/pyeventsystem :alt: build status

.. image:: https://codecov.io/gh/CloudVE/pyeventsystem/branch/master/graph/badge.svg :target: https://codecov.io/gh/CloudVE/pyeventsystem :alt: coverage status

pyeventsystem

pyeventsystem is an event-driven middleware library for Python. In addition to providing a mechanism for subscribing and listening to events, it also provides a mechanism for intercepting functions, thus making it suitable for writing middleware. By intercepting functions, middleware can be injected before, after or even replacing the original function. It also provides capabilities for grouping related event handlers into middleware classes, making it easier to manage installable middleware.

Simple Example

.. code-block:: python

from pyeventsystem.middleware import SimpleMiddlewareManager
from pyeventsystem.middleware import dispatch
from pyeventsystem.middleware import observe


class MyMiddleWare(object):

    def __init__(self, event_dispatcher):
        self.events = event_dispatcher

    @dispatch("a.series.of.unfortunate.events", priority=2500)
    def perform_villainy(self, name):
        return "Drop ACME Anvil on " + name

    @observe("a.series.of.unfortunate.events", priority=2400)
    def pre_log_villainy(self, event_args, name):
        print("Prepping for villainy: " + name)

    @observe("*.unfortunate.events", priority=2600)
    def post_log_villainy(self, event_args, name):
        print("Result of villainy: {0}".format(event_args['result']))


manager = SimpleMiddlewareManager()
myobj = MyMiddleWare(manager.events)
manager.add(myobj)
myobj.perform_villainy("RoadRunner")

In this example, we have intercepted the perform_villainy function, and observed the function both before and after execution.

The output is:

.. code-block:: console

Prepping for villainy: RoadRunner
Result of villainy: Drop ACME Anvil on RoadRunner

Metadata

Release files for pyeventsystem 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyeventsystem 0.1.0
File Size Uploaded
pyeventsystem-0.1.0.tar.gz 13.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyeventsystem 0.1.0
File Interpreter ABI Platform
pyeventsystem-0.1.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 28.5 kB

Release files / pyeventsystem-0.1.0.tar.gz

Download URL pyeventsystem-0.1.0.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4a3d199759a040d2cd17f8b4293cc1c3f3c2ae50ae531fb5f9f955a895fca8b9
BLAKE2b-256 checksum
How to use checksums
b51ef7499ca118bd5186072fffc3922ae58abe501c4633b1d6da25e30b16b841
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

Release files / pyeventsystem-0.1.0-py2.py3-none-any.whl

Download URL pyeventsystem-0.1.0-py2.py3-none-any.whl
Size 15.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2a651eca3ec0b7e8600e2d4f042ab519b2d3bf74969e783b7a51fb87c506a7a6
BLAKE2b-256 checksum
How to use checksums
e5d399dac9569f8e90c21889a6d91d187404eb831ceef4638c98c3ff8915ae44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page