I’m going to be honest, I don’t really like Java for the frontend, but it is very widely used and I find it very nice for whatever’s not the frontend.
There must be a lot of java guys who think the same and there are projects like Groovy and Grails endorsed by Sun, I was impressed to see even a Ruby container in glassfish v3.
I haven’t tried ruby yet so I cannot comment on that, and I wanted to try something simple with jython so I decided to try bfg, my first attempts didn’t work so I asked for help on the bfg developers list, and a loooot of help from Chris McDonough I got it working.
It isn’t soo nice yet, and zcml configuration doesn’t work but at least it’s usable.
Here is how to get it working, since some changes were just made by Chris on the development’s trunk you need subversion and mercurial to get the repos.
First of all get jython I tried this with 2.5.1, it is pretty simple to install it.
Next you need to get setuptools, you can get that from pypi make sure to download the source version (the one that ends with .tar.bz2)
To install it uncompress it, get into the directory and run:
${JYTHONDIR}/bin/jython setup.py install |
Since we are going to be testing a lot it’s better to install virtualenv do it with
${JYTHONDIR}/bin/easy_install virtualenv |
Now create a folder where you can start working, in this case I’ll assume it’s called BFG
Get into the BFG folder and create a virtual env.
cd BFG ${JYTHONDIR}/bin/virtualenv --no-site-packages sys source sys/bin/activate |
After this you’ll have you virtualenv’s jython and easy_install in your path.
It’s time to download latest versions from repos, and also http://pypi.python.org/packages/source/z/zope.schema/zope.schema-3.5.4.tar.gz this from pypi
svn co http://svn.repoze.org/repoze.bfg/trunk/ repoze.bfg svn co http://svn.repoze.org/repoze.bfg.jinja2/trunk/ repoze.bfg.jinja2 hg clone http://dev.pocoo.org/hg/jinja2-main jinja2 tar xfvj zope.schema-3.5.4.tar.gz |
Now we need to change a few things head into the zope.schema-3.5.4 folder and edit this file src/zope/schema/_bootstrapfields.py
In line 31 you should see something like:
class ValidatedProperty(object): def __init__(self, name, check=None): self._info = name, check def __set__(self, inst, value): name, check = self._info if value != inst.missing_value: if check is not None: check(inst, value) else: inst.validate(value) inst.__dict__[name] = value |
Add a __get__ method like this:
class ValidatedProperty(object): def __init__(self, name, check=None): self._info = name, check def __set__(self, inst, value): name, check = self._info if value != inst.missing_value: if check is not None: check(inst, value) else: inst.validate(value) inst.__dict__[name] = value def __get__(self, inst, owner): name, check = self._info return inst.__dict__[name] |
Now install zope.schema with:
jython setup.py install |
Now get into the jinja2 directory, here you should patch your file with the patch provided below
patch -p1 < jinja2_jython.patch |
Now for install jinja2, repoze.bfg and repoze.bfg.jinja2 in that order, for each package just go into the directory and run:
${JYTHONDIR}/bin/jython setup.py install |
You can create a project with paster now, but it won’t work right away, because zcml doesn’t work with jython but you can get it working.
Here is a sample project tweaked to work, just download it and run:
paster serve MyProject.ini |
I hope this works for you and that you find it useful
UPDATE Chris just told me that zope.schema now passes tests under jython, so it’s no longer necesarry to change the _bootstrapfields.py file.
Another thing, I forgot to mention that you need to run jython setup.py develop with the MyProject egg.

Thanks for the detailed post! It’s really great to see more Zope related technologies working with Jython. Also, I don’t think it is widely known that virtualenv and setuptools work with Jython now.