Skip to main content

A simple fork of django.dispatch for use as a standalone Python PubSub library.

Use

Paperboy’s dispatch may be used identically to Django’s; they are essentially the same.

A “signal dispatcher” helps decoupled applications notify each other of events. A library, for instance, may thereby invoke callables of dependent applications, without having been programmed for them, and without needing to extend or patch the library. The signal notifies registered receivers on behalf of their sender, via the dispatcher.

For example, say we have a pizza delivery library. Its job is only to communicate with the pizza delivery Internet API; rather than program a single user notification pipeline, this library’s developer wants to send a signal to subscribed receivers that a pizza has been delivered:

from dispatch import Signal

delivered = Signal(providing_args=['parlor'])

Upon learning that a pizza has been delivered, the library could then send this signal:

class PizzaAPI(object):

    def check(self):
        response = self.get_response()
        if response.status == 'delivered':
            delivered.send(sender=self, parlor=response.parlor)

However, a signal’s not much use if no one’s around to receive it. Applications making use of the pizza delivery library may register receivers with the dispatcher via the signal they intend to receive:

delivered.connect(popup_window)

or using the receiver decorator:

from dispatch import receiver

@receiver(delivered)
def popup_window(sender, parlor, **kws):
    ...

See Django’s documentation for more information.

Configuration

Paperboy’s dispatch is ready for use. However, its Signal, as in Django, respects a debugging mode, under which receivers are inspected upon connection. Paperboy does not supply a configuration framework of its own, but you may trivially configure it, as in the below examples.

Globally:

from dispatch import Signal
Signal.debug = True

By application:

from dispatch import Signal

class AtariSignal(Signal):

    debug = True

And with increasing sophistication:

from dispatch import Signal
from atari.conf import settings

class AtariSignal(Signal):

    @property
    def debug(self):
        return settings.DEBUG

Installation

With an installation tool such as pip:

pip install Paperboy

From source:

python setup.py install

Running tests

Via the setup.py file:

python setup.py test

Release files for Paperboy 1.0.1

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

Source distribution (sdist)

Source distribution for Paperboy 1.0.1
File Size Uploaded
Paperboy-1.0.1.tar.gz 15.0 kB Details

Release files / Paperboy-1.0.1.tar.gz

Download URL Paperboy-1.0.1.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
68c65250c51ac2f659034e8f91cd26afa9242014c3455e577668f60e49cd2d34
BLAKE2b-256 checksum
How to use checksums
d33714192e859ba8dd79fecd57838c63b7ef18c6de328a1983c4cba8a487049b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

1.0.0

1 release file

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