Base class for any kind of notifications. Inherit from this class to create your own notification types and backends.
Subclasses need to implement notify().
A name for this notification.
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: |
|
---|
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)
Registry mapping notification names to backends