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

Easy to use server push solution, highly integrated with django.


* Django
* Tornadio2


For any django view, you can define an update function by just naming it the
same as view function and appending "_update".

Lets say we have a view called hello that says hello to the user:

def hello(request):
return HttpResponse('Hey, %s!' % request.user.username)

Now we can define hello_update that returns what types of updates should affect
this page, and how will it be serialized:

* We can use default serializer and just define what fields we need:

def hello_update(request):
return [{'name':'username_change', 'model':User, 'params':{'pk'}, 'data':{'username':'object.username'}}]

But then we have to write a special bit of JavaScript to handle this:

$(document).bind('serverpush_username_change', function(event, data) {
$('body').html('Hey, ' + data.username + '!');

* We can write a custom serializer:

def hello_update(request):
# 'data' parameter is optional, and it is directly passed to the serializer
return [{'name':'reload', 'model':User, 'params':{'pk'}, 'serializer':hello_update_serializer}]

def hello_update_serializer(request, user, data):
return 'Hey, %s!' % user.username

And now we can either have a special JS for every page, or we can generalize
them a bit, and have just one or a few (name in the update function is name for
the JavaScript event).

$(document).bind('serverpush_reload', function(event, data) {

In this example I called it reload, because all it does is swapping the HTML.

* Or we can just use hello view function for serializing:

def hello_update(request):
return [{'name':'reload', 'model':User, 'params':{'pk'}, 'serializer':'hello'}]

And change hello header a bit:

def hello(request, user=None, data=None):

And have one general JavaScript for the whole site / updates like that
(of course we can mix all three types of updates):

$(document).bind('serverpush_reload', function(event, data) {

Why django-serverpush?

Because it's super easy to use, and requires very little additional code to
transform a traditional django application.


1. Install this package

sudo python install

2. Update

Add "serverpush" to INSTALLED_APPS and
"serverpush.client.context_processor" to TEMPLATE_CONTEXT_PROCESSORS.
Also add the following constants:


3. Add a timestamp div to your template (for history to work)

<div id="generated_timestamp" style="display:none">
{{ generated_timestamp }}

4. Run it by calling ./ runserverpush

Running Demo

1. Create sqlite file

./ syncdb

2. Run django development server

./ runserver

3. Run serverpush server

./ runserverpush

4. Navigate to localhost:8000 in multiple browsers/windows/tabs and observe the counter

Browser support

It's based on, so it should work in all major browsers.
Currently there are problems with opera (because it doesn't allow cross port
XHR, and JSONP makes it "load"), but I'm working on resolving them. Simple
solution would be to proxy XHR.
Release History

Release History


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

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 (11.1 kB) Copy SHA256 Checksum SHA256 Source Mar 21, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS 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