notification.backends.base module

class notification.backends.base.NotificationBackend[source]

Bases: object

archive_list(user)[source]

Retrieve all the messages in user archive

Parameters:user – a user
Returns:an iterable containing notification
archive_store(users, notification)[source]

Store a Notification instance in the archive for a list of users.

Parameters:
  • users – an iterable containg user instances
  • notification – Notification instance to persist in archive
Returns:

None

Raises:

MessageTypeNotSupported if notification cannot be managed by current backend

can_handle(notification)[source]

Determine if this backend can handle this notification

Parameters:notification – Notification instance
Returns:True if can handle, False otherwise
create_message(level, payload, date=None)[source]

Create and return a Notification instance. Instance types depends on backends implementation.

Parameters:
  • level – a notification level (could be seen as priority)
  • payload – a dict payload serializable (depends on implementation detail: JSON / MsgPack / whatever)
  • date – a date to deliver the notification on (default: now)
Returns:

a Notification instance

inbox_delete(user, notification_id)[source]

Remove a Notification instance from user inbox.

Parameters:
  • user – a user instance
  • notification_id – a notification identifier
Returns:

None

inbox_get(user, notification_id)[source]

Get a Notification from a user inbox.

Parameters:
  • user – a user instance
  • notification_id – a notification identifier
Returns:

a notification instance

Raises:

MessageDoesNotExists if notification_id is not found

inbox_list(user)[source]

Retrieve all the notifications in a user inbox.

Parameters:user – a user instance
Returns:an iterable containing Notification instances
inbox_purge(user)[source]

Delete all the notifications in user inbox.

Parameters:user – a user instance
Returns:nothing.
inbox_store(users, notification)[source]

Store a Notification instance in the inbox for the list of users.

Parameters:
  • users – an iterable containing users instances.
  • notification – a notification instance to persist in the inbox
Raises:

MessageTypeNotSupported if Notification cannot be managed by the current backend

Returns:

nothing