/django-spdy

Experimental project to run Django 1.4.5 on Jetty web server. Django is packaged in a WAR container using Jython and django-jython module. The main goal is to use Jetty SPDY push capabilities to serve Django web pages.

Primary LanguagePython

Django-SPDY

The main goal of this experimental project is to deliver Django 1.4.5 web pages using Jetty web container. The usefulness of this is to use Jetty SPDY support together with the capabilities to push associated resources of a main request (SPDY push). If you want further information, there is an article about this experiment.

Django-SPDY up and running

To achieve this integration and build war package it's necessary to use Jython interpreter with django-jython app. Follow these step if you want to be up and running with this experiment!

Prerequisite

Note: NPN implementation relies on modifications of OpenJDK classes so you need to use the correct version according to your JDK version. You can find a list of the correct NPN library here. NPN library can be put on your $JETTY_HOME.

Virtualenv configuration

Virtualenv must be created using jython interpreter as follows (be sure that jython interpreter is in your $PATH):

$ mkvirtualenv django-spdy -p jython
$ workon django-spdy
$ pip install -r requirements.txt

Build war package

Be sure that 'doj' is enabled on Django INSTALLED_APPS. Then use:

$ jython manage.py war

Jetty configuration

First you must configure your $JETTY_HOME/start.ini to enable a customized XML configuration and SPDY support. Edit this line:

OPTIONS=Server,spdy

and also be sure that in Configuration files section these elements are enabled:

etc/jetty.xml
etc/jetty-deploy.xml
etc/jetty-webapps.xml
etc/jetty-spdy-push.xml

Jetty SPDY push configuration file

To have SPDY up and running you should provide jetty-spdy-push.xml that is available in download section of this repository. Feel free to use it as a basic configuration for this experiment.

And now?

Deploy your Django app (django_spdy.war) inside Jetty webapps folder ($JETTY_HOME/webapps/root.war). Now you can run jetty:

$ java -Xbootclasspath/p:npn-boot-{YOUR_NPN_VERSION}.jar -jar start.jar

Ready to push?