Documentation for pulsar 0.9.2. For development docs, go here.

Django with Pulsar

The code for this example is located in the examples.djangoapp.manage module.

This is a web chat application which illustrates how to run a django site with pulsar and how to include pulsar asynchronous request middlewares into django. Requires django 1.4 or above. To run:

python manage.py pulse

If running for the first time, issue the:

python manage.py syncdb

command and create the super user.

This example uses the django pulse application.

Message and data backend

By default, messages from connected (websocket) clients are synchronised via the pulsar data store which starts when the django site starts. It is possible to specify a different data store via the data-store option.

For example, it is possible to use redis as an alternative data store simply by issuing the following start up command:

python manage.py pulse --data-store redis://127.0.0.1:6379/3

Views and Middleware

Check the examples.djangoapp.djchat.settings module to see how this classes are used.

class examples.djangoapp.djchat.views.Chat[source]

WS handler managing the chat application.

get_pubsub(websocket)[source]

Create the pubsub handler if not already available

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

A new websocket connection is established.

Add it to the set of clients listening for messages.

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

Leave the chat room

on_message(websocket, msg)[source]

When a new message arrives, it publishes to all listening clients.

class examples.djangoapp.djchat.views.middleware[source]

Django middleware for serving the Chat websocket.



Table Of Contents

Previous topic

A Task Queue with a JSON-RPC Api

Next topic

Twitter Streaming

This Page