yell

class yell.MetaNotification[source]

Metaclass that stores all notifications in the registry.

class yell.Notification[source]

Base class for any kind of notifications. Inherit from this class to create your own notification types and backends.

Subclasses need to implement notify().

name = None

A name for this notification.

notify(*args, **kwargs)[source]

A method that delivers a notification.

yell.notify(name, *args, **kwargs)[source]

Send notifications. If backends==None, all backends with the same name will be used to deliver a notification.

If backends is a list, only the specified backends will be used.

Parameters:
  • name – The notification to send
  • backends – A list of backends to be used or None to use all associated backends

yell.decorators

yell.decorators.notification(name=None, backends=None)[source]

Decorator to simplify creation of notification backends.

Example :
from yell.decorators import notification
from yell import notify 

@notification('like')
def like_email(user, obj):
    send_mail("%s liked %s" % (user, obj), "No/Text", "noreply@example.com",
        [obj.user.email])

@notification('like')
def like_db(user, obj):
    DBNotification.objects.create(user = user, obj = obj, type = 'like')

@notification('like')
def like(*args, **kwargs):
    pass

# Use all backends
notify('like', user = user, obj = obj)        
like.notify(user = user, obj = obj)

# Only use the email backend
like_email.notify_once(user = user, obj = obj)

yell.registry

yell.registry.notifications = {}

Registry mapping notification names to backends

Project Versions

Table Of Contents

This Page