Leo's Technical Blog

Django on Jython: What I've done until now

Introduction

user

Leo Soto


python, jython, django

Django on Jython: What I've done until now

Posted by Leo Soto on .
Featured

python, jython, django

Django on Jython: What I've done until now

Posted by Leo Soto on .

Now that Jython has released it's 2.2 version and has some progress on 2.3 features, I decided to try Django on it. As you can see on thte screenshot above, I got the development server running. And there is some progress on getting database syncing to work:

lsoto@colinux:~/src/hellodjango$ createdb hellodjango
CREATE DATABASE
lsoto@colinux:~/src/hellodjango$ CLASSPATH=/usr/share/java/postgresql.jar  ~/src/jython/trunk/jython/jython.sh manage.py syncdb
Creating table auth_permission
Creating table auth_user
Creating table auth_message
Creating table auth_group
Creating table django_content_type
Creating table django_session
Creating table django_site

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username: admin
E-mail address: admin
Error: That e-mail address is invalid.
E-mail address: admin@admin.com
Warning: Problem with getpass. Passwords may be echoed.
Password: 123
Warning: Problem with getpass. Passwords may be echoed.
Password (again): 123
Traceback (innermost last):
  File "manage.py", line 11, in ?
[...]
  File "/home/lsoto/src/django.svn.trunk/django/db/backends/postgresql_zxjdbc/base.py", line 86, in execute
Error: ERROR: la columna «is_staff» es de tipo boolean pero la expresión es de tipo integer [SQLCode: 0], [SQLState: 42804]

So here are the steps I've done until now:

  1. Get the development (SVN) source of both project. As Django requires python >= 2.3, I didn't tried Jython 2.2. I'm using mercurial to maintain my "branch", so I made a mercurial mirror of django svn repository and another mercurial repository for my changes
  2. Build Jython using ant
  3. Add Django directory to Jython path (copying the registry file to dist/ and editing the python.path line).
  4. Add some modules from Jython's CPythonLib/ to dist/Lib directory: optparse.py, gettext.py, locale.py and getpass.py4. Cook a simple script to run jython from the shell
  5. Apply these two patches to jython. The later is not really a fix, but it allowed me to forget that bug for a while.
  6. Modify django source where needed:
    All the changes concerning Django are on my mercurial repository, so you can easily get a patched source tree using mercurial:
$ hg clone https://hg.leosoto.com/django.jythonport

Pending short-term goals:

  • syncdb should work* The test suite should run