Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install juggernaut

How to install juggernaut

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install juggernaut
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.2 Available View build log
Windows (64-bit)
0.2 Available View build log
Mac OS X (10.5+)
0.2 Available View build log
Linux (32-bit)
0.2 Available View build log
Linux (64-bit)
0.2 Available View build log
 
Dependencies
Imports
Lastest release
version 0.2 on Dec 6th, 2011

Dead simple Python library that connects to a juggernaut via redis. It also provides a very basic roster implementation that can be used as a daemon process to manage online users.

Basic usage

How to send a message to all subscribers of a channel:

from juggernaut import Juggernaut
jug = Juggernaut()
jug.publish('channel', {'message': 'Hello World!'})

Connection Events

Juggernaut also allows you to subscribe to events (new subscription, unsubscribe event) so that you can respond to users going online and offline:

from juggernaut import Juggernaut
jug = Juggernaut()
for event, data in jug.subscribe_listen():
    if event == 'subscribe':
        ...
    elif event == 'unsubscribe':
        ...

Since this is quite common this library also implements a Roster that can group multiple connections to the same user. For grouping this it uses a key in the meta part of the message. The default is user_id in the meta object.

Example usage:

from juggernaut import Juggernaut, RedisRoster
jug = Juggernaut()
roster = RedisRoster(jug)
roster.run()

By default it keeps the number of online users in redis so that you can use the roster class to see if users are online:

>>> roster.get_online_users()
[42, 23]
>>> roster.is_user_online(42)
True
>>> roster.is_user_online(99)
False

If you want to respond to users signing in and out you need to override the on_signed_in and on_signed_out methods:

class MyRoster(RedisRoster):
    def on_signed_in(self, user_id):
        print 'User signed in', user_id
    def on_signed_out(self, user_id):
        print 'User signed out', user_id

You can for instance use juggernaut to broadcast that to other users that signed in.

copyright:
  1. 2011 by Armin Ronacher.
license:

BSD, see LICENSE for more details.

Subscribe to package updates

Last updated Dec 6th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.