django-async-messages

Software Screenshot:
django-async-messages
Software Details:
Version: 0.1.4
Upload Date: 20 Feb 15
Developer: David Winterbottom
Distribution Type: Freeware
Downloads: 17

Rating: nan/5 (Total Votes: 0)

django-async-messages is a simple asynchronous messages for Django.

Questions

What problem does this solve?

Suppose a user instigates an expensive task that you are processing offline (eg using Celery). This library provides a simple mechanism for notifying the user when the task is finished.

For instance, you might use Celery to generate a large report and then use this library to notify the user that their report is ready to be downloaded.

How does it work?

A cache is used to persist the messages, and middleware is used to pick these up and add them to Django's messages. All very simple.

Aren't there other libraries that do this?

Yes, there are - but they solve the problm in different ways:

- django-offline-messages - this provides an alternative storage backend that Django's messages framework can use.
- django-notifications

Install

From PyPI (stable):

pip install django-async-messages

From Github (unstable):

pip install
git+git://github.com/codeinthehole/django-async-messages#egg=djang-async-messages


Add async_messages.middleware.AsyncMiddleware to your INSTALLED_APPS. Ensure it comes after django.contrib.messages.middleware.MessageMiddleware.

You need to have a cache set up in you settings for this to work. As usual, memcache is the best choice.

Use

Send a message to a single user:

>>> from async_messages import message_user
>>> from django.contrib.auth.models import User
>>> barry = User.objects.get(username='barry')
>>> message_user(barry, "Barry, your report is ready")


Send a message to lots of users:

>>> from async_messages import message_users
>>> staff = User.objects.filter(is_staff=True)
>>> message_users(staff, "All budgets must be spent by the end of the day")


Specify message level:

>>> from django.contrib.messages import constants
>>> message_users(staff, "Boom!", constants.WARNING)

What is new in this release:

  • Altered dependency on Django to be only 1.2+

What is new in version 0.1.2:

  • Altered dependency on Django to be only 1.2+

Requirements:

  • Python
  • Django

Other Software of Developer David Winterbottom

purl
purl

20 Feb 15

django-rickroll
django-rickroll

20 Feb 15

csvfilter
csvfilter

1 Mar 15

Comments to django-async-messages

Comments not found
Add Comment
Turn on images!