Differences between revisions 17 and 88 (spanning 71 versions)
Revision 17 as of 2007-09-10 18:33:34
Size: 2966
Editor: n01-114
Comment: Some clarification about __builtins__. Reordered minor annoyances too.
Revision 88 as of 2014-05-22 23:24:19
Size: 2104
Editor: AdamBurke
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== Gaps between Jython and Django == == Using Django on Jython ==
Line 3: Line 3:
=== Mayor problems === Finally, Django works on Jython, without any special patching. Here are the steps to get Django on Jython running:
Line 5: Line 5:
 * Jython does not support non-str keys in {{{__dict__}}} right now. If Groves' HashMap replacement works out maybe this issue will disappear. Problem encountered in {{{django/utils/_threading_local.py}}}.
 * Unicode string interpolation doesn't work in the general case.
   * There is also a problem with the algorithm deciding whether to call {{{__str__}}} or {{{__unicode__}}}. More research is needed, but it affects the lazy string evaluation on which the Django i18n system relies.
 * Something goes wrong with {{{re.compile(u"([\u0080-\uffff])")}}} in {{{django/utils/text.py}}} I think it is a lacking in our array implementation but this needs more investigation.
   * See [http://sourceforge.net/tracker/index.php?func=detail&aid=1544953&group_id=12867&atid=112867 bug 1544953]
 * metaclasses need to know the {{{__module__}}} of its classes [http://sourceforge.net/tracker/index.php?func=detail&aid=1781500&group_id=12867&atid=112867 bug] [http://sourceforge.net/tracker/index.php?func=detail&aid=1789137&group_id=12867&atid=312867 patch]
 * {{{inspect.getargs()}}} doesn't work.
   * That's because {{{co_code}}} isn't supported by {{{PyTableCode}}}.
     * '''But''', {{{co_code}}} is used by {{{getargs()}}} only to discover anonymous tuple arguments. Commenting such section seems to be enough to get the other cases working.
 * inspect.isclass(time) shouldn't return True [http://sourceforge.net/tracker/index.php?func=detail&aid=1786009&group_id=12867&atid=112867 bug]
 1. First, get a fresh version of Jython. Any release after 2.5.0 should work fine.
Line 16: Line 7:
=== Minor annoyances ===  2. Check out and install Django 1.2.5.
Line 18: Line 9:
 * slice should be a type, not a function.
 * {{{PyBoolean.__tojava__}}} returns an {{{Integer}}}
   * It affects zxJDBC unless a DataHandler sets the right type of boolean parameters. Fortunately, JDBC30DataHandler does this thing, at least on my limited tests -- LeonardoSoto
 * Jython does not have {{{os.W_OK}}} needed in {{{django/core/management.py}}}. This probably will not be hard to add this since {{{java.io.File}}} has a {{{canWrite()}}}.
   * {{{os.chmod}}} should be implemented too (After checking for write permissions, Django will try to change them if necessary).
     * That's hard. Maybe Django shouldn't check for permissions if running on Jython.
 * Jython does not have {{{__builtins__}}} as a module. Django adds "_" as a convenience method for calling gettext in {{{django/conf/__init__.py}}}.
    * According to the Python docs, {{{__builtins__}}} is a implementation detail and shouldn't be used by portable applications, so it's a Django problem
    {{{
$ svn co http://code.djangoproject.com/svn/django/trunk/ django
$ cd django
$ jython setup.py install
}}}
    
    You may also like to make an alias for "django-admin.py". Very useful if you also use Django with CPython:
Line 27: Line 17:
    {{{
$ alias django-admin-jy="jython /path/to/jython-dev/dist/bin/django-admin.py"
}}}
Line 28: Line 21:
=== Already Fixed ===  3. Download and install the latest release of django-jython:
Line 30: Line 23:
 * Jython does not have {{{sys.stdout.isatty}}}. Jython should get added to the exclusions around that call in {{{django/core/management.py}}} (win32 and 'Pocket PC' are already excluded).
   * Fixed in [http://code.djangoproject.com/changeset/6032 Django changeset 6032]
 * stringmap (or the {{{__dict__}}} implementation) needs a {{{pop(o)}}} method.
    {{{
$ wget http://django-jython.googlecode.com/files/django-jython-1.2.0b1.tar.gz
$ tar xvfz django-jython-1.2.0b1.tar.gz
$ cd django-jython-1.2.0b1
$ jython setup.py install
}}}

 4. Start a project.
    {{{
$ django-admin-jy startproject myproject
}}}

 5. Edit `myproject/settings.py` and change the `DATABASE_ENGINE` to `doj.backends.zxjdbc.postgresql`.

At this point, you can follow the great [[http://djangoproject.com/documentation/|Django documentation]], remembering to use the `jython25` command instead of `python`, and the `JYTHONPATH` variable instead of `PYTHONPATH`. Have fun!

== Deployment ==

See http://packages.python.org/django-jython/war-deployment.html

== Troubleshooting ==

=== Running the test suite on Windows ===

Seems like there is an issue with popen() on windows, which blocks the Django test suite. You can try skipping the offending test using these two patches (against Django 1.0.2), written by Victor Ng:

 * http://tinyurl.com/bqfcco
 * http://tinyurl.com/aarjx2

'''Update (03/04/11): Not sure if this is an issue any longer, please edit if you run into it using the latest versions'''

=== Using MS SQL Server ===

The Django-Jython 1.2.0b1 release is in beta as of 03/04/11. It should be compatible with Oracle, MySQL, and PostgreSQL. If you need to use MS SQL Server, you will still need to use Django version 1.1.x until otherwise noted.

Using Django on Jython

Finally, Django works on Jython, without any special patching. Here are the steps to get Django on Jython running:

  1. First, get a fresh version of Jython. Any release after 2.5.0 should work fine.
  2. Check out and install Django 1.2.5.
    • $ svn co http://code.djangoproject.com/svn/django/trunk/ django
      $ cd django
      $ jython setup.py install
      You may also like to make an alias for "django-admin.py". Very useful if you also use Django with CPython:
      $ alias django-admin-jy="jython /path/to/jython-dev/dist/bin/django-admin.py"
  3. Download and install the latest release of django-jython:
    • $ wget http://django-jython.googlecode.com/files/django-jython-1.2.0b1.tar.gz
      $ tar xvfz django-jython-1.2.0b1.tar.gz
      $ cd django-jython-1.2.0b1
      $ jython setup.py install
  4. Start a project.
    • $ django-admin-jy startproject myproject
  5. Edit myproject/settings.py and change the DATABASE_ENGINE to doj.backends.zxjdbc.postgresql.

At this point, you can follow the great Django documentation, remembering to use the jython25 command instead of python, and the JYTHONPATH variable instead of PYTHONPATH. Have fun!

Deployment

See http://packages.python.org/django-jython/war-deployment.html

Troubleshooting

Running the test suite on Windows

Seems like there is an issue with popen() on windows, which blocks the Django test suite. You can try skipping the offending test using these two patches (against Django 1.0.2), written by Victor Ng:

Update (03/04/11): Not sure if this is an issue any longer, please edit if you run into it using the latest versions

Using MS SQL Server

The Django-Jython 1.2.0b1 release is in beta as of 03/04/11. It should be compatible with Oracle, MySQL, and PostgreSQL. If you need to use MS SQL Server, you will still need to use Django version 1.1.x until otherwise noted.

DjangoOnJython (last edited 2014-05-22 23:24:19 by AdamBurke)