Django on Jython Leo Soto
Not exactly “ Summer  of Code”  but... ...worked incredibly well! And that's why I'm here :)
Why Django  on Jython ? Integration Deployment Performance
Jython
Jython Implementation of Python Compiles to Java bytecode No  foo.pyc It's  foo$py.class
Jython Makes Java look like Python And Python like Java to Java programs No GIL, no ref counting
>>> from __future__ import GIL Traceback (most recent call last): ... SyntaxError: Never going to happen! (<stdin>, line 1)
State of Jython 2.5 99.4% of ~5700 test cases passing  ~20% faster on PyStone [FWIW]  2.5 alpha 2 last weekend for DjangoCon September/October beta  December/January final
Java - What We Like Great systems programming language Well-defined memory, concurrency model Standard libraries - concurrent collections
Java Ecosystem Excel, thru Apache POI support of OLE Full text search with Lucene Scalability with Hadoop, Hbase Scala, JRuby, Rhino...
Biggest Benefit Just use what is good out there in the Java ecosystem
Now...
Why in the name of... J2EE was a big, horrible mistake But lessons have been learned And it’s possible to use that infrastructure
“We write Java so you don’t  have  to.”
Combination In Python code: Django app framework Models, templates, forms Business logic - as complex as necessary In Java code (optional) Performant infrastructure
Deployment Options Java App Servers!
modjy Servlets <=> WSGI
WAR! Web ARchive format Standard deployment of Java webapps Just a zip file with a standard directory layout
A Django WAR: jython manage.py war --include-java-libs=XXX.jar
WAR format for DoJ |-- WEB-INF |  |-- lib  ← JDBC driver |  `-- lib-python  |  |-- Lib  ← Python Std. library |  |-- django  |  |-- doj  |  |-- modjy-django |  `-- mysite  ← Your code! `-- media  ← (and media files)
What’s missing PIL! so no Photolog Oracle, MySQL, SQLServer backends But that’s easy zxJDBC: JDBC <=> DB-API
Django Backend Dev Features Operations Client Creation and Introspection Validation Wrapper
 
Demo
Thanks!

Django On Jython (for Portland and Boulder Python user groups presentations)

  • 1.
  • 2.
    Not exactly “Summer of Code” but... ...worked incredibly well! And that's why I'm here :)
  • 3.
    Why Django on Jython ? Integration Deployment Performance
  • 4.
  • 5.
    Jython Implementation ofPython Compiles to Java bytecode No foo.pyc It's foo$py.class
  • 6.
    Jython Makes Javalook like Python And Python like Java to Java programs No GIL, no ref counting
  • 7.
    >>> from __future__import GIL Traceback (most recent call last): ... SyntaxError: Never going to happen! (<stdin>, line 1)
  • 8.
    State of Jython2.5 99.4% of ~5700 test cases passing ~20% faster on PyStone [FWIW] 2.5 alpha 2 last weekend for DjangoCon September/October beta December/January final
  • 9.
    Java - WhatWe Like Great systems programming language Well-defined memory, concurrency model Standard libraries - concurrent collections
  • 10.
    Java Ecosystem Excel,thru Apache POI support of OLE Full text search with Lucene Scalability with Hadoop, Hbase Scala, JRuby, Rhino...
  • 11.
    Biggest Benefit Justuse what is good out there in the Java ecosystem
  • 12.
  • 13.
    Why in thename of... J2EE was a big, horrible mistake But lessons have been learned And it’s possible to use that infrastructure
  • 14.
    “We write Javaso you don’t have to.”
  • 15.
    Combination In Pythoncode: Django app framework Models, templates, forms Business logic - as complex as necessary In Java code (optional) Performant infrastructure
  • 16.
  • 17.
  • 18.
    WAR! Web ARchiveformat Standard deployment of Java webapps Just a zip file with a standard directory layout
  • 19.
    A Django WAR:jython manage.py war --include-java-libs=XXX.jar
  • 20.
    WAR format forDoJ |-- WEB-INF | |-- lib ← JDBC driver | `-- lib-python | |-- Lib ← Python Std. library | |-- django | |-- doj | |-- modjy-django | `-- mysite ← Your code! `-- media ← (and media files)
  • 21.
    What’s missing PIL!so no Photolog Oracle, MySQL, SQLServer backends But that’s easy zxJDBC: JDBC <=> DB-API
  • 22.
    Django Backend DevFeatures Operations Client Creation and Introspection Validation Wrapper
  • 23.
  • 24.
  • 25.