This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

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.

Release History

Release History

0.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
juggernaut-0.2.tar.gz (3.7 kB) Copy SHA256 Checksum SHA256 Source Dec 6, 2011

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting