Django on Jython, PyCon 2009

Embed Size (px)

Citation preview

Django on Jython

Jim Baker

Leo Soto

Jython Status

Shipped 2.5
(beta3)

Greatly improved compatibility

setuptools

virtualenv

nose

etree

web2py

Django + Jython:
Why?

Installing this Django app...

...in an Enterprise Infrastructure

http://www.flickr.com/photos/purpleslog/231478071

(I mean, this kind of enterprise infrastructure)

Didn't work quite well

http://www.flickr.com/photos/21054697@N03/2053923652

Guess howmuch time ittook

http://www.flickr.com/photos/21054697@N03/2053923652

We like Python

They need Java

Jython

http://www.flickr.com/photos/vicintosh87/2618725412/

Avoiding Java

Sneaking Python

Is that it?

No, it is more than that!

(if you want)

Examples...

Python/Django

Install Django

Install 3rd party deps

Install app(s)

Tweak settings.py

Configure web server

Make sure everything is consistent

Steps to Deploy a Web Application

Java

Copy/upload WAR package

Steps to Deploy a Web Application

Java libs can eat complex Excel data!

http://www.flickr.com/photos/purpleslog/231478071

We can reuse what's good on the Java ecosystem!

Django + Jython:
Architecture

The cool side of Java

System Programming

Concurrency Model

Memory Model

http://www.flickr.com/photos/purpleslog/231478071

$ jython2.5

...

>>> from __future__ import GIL

$ jython2.5

...

>>> from __future__ import GIL

Traceback (most recent call last):
(no code object) at line 0
File "", line 1

SyntaxError:

Never going to happen!

On the other hand...

J2EE was a big, horrible mistake

The right tool for the right job!

http://www.flickr.com/photos/dipster1/1403240351

Java:

Performance,
Heavy lifting,
Pre-existing infrastructure

Jython:

Everything else :)

Deployment

App Servers:

Already there,
lots of features

http://flickr.com/photos/tomloudon/322172413/sizes/l/

Let's use their force!

Deployment Options

Java app servers - show some horizontal scaling; also management - sys admins know how to do this!

Hardened - it runs on the JVM

vs Google App Engine

Its Django 1.0

We have Unicode, internationalization, ORM, unit tests, admin, shell, everything!

And we can use Java analogues:

BigTable HBase, Hypertable

MapReduce Hadoop

Add pictures for app engine, HBase, Hadoop

WAR!

Web ARchive format

Standard deployment for Java app servers

Just a bunch of files with a standard directory layout and manifest

$ jython manage.py war

--include-java-libs=jdbcdriver.jar

100%
self-contained!

WAR format for DoJ

|-- WEB-INF

| |-- lib

| `-- lib-python

| |-- Lib

| |-- django

| |-- doj

| `-- mysite

`-- media

super simple bundling!

IDE Integration

Again, why?

Quick Start!

Let PeopleExplore

Re-factoring

One place torule them all

Let see how that'd be with Django...

Demo

Summary

Questions?

Thanks!

Jim's Blog: http://www.zyasoft.com/pythoneering/

Leo's Blog:
http://blog.leosoto.com

Twitter: jimbaker, leosoto

http://www.flickr.com/photos/purpleslog/231478071

http://www.flickr.com/photos/21054697@N03/2053923652

http://www.flickr.com/photos/vicintosh87/2618725412

http://www.flickr.com/photos/dipster1/1403240351

Images used under CC license