I wanted to rewrite Mango in Python for a while now, but couldn’t determine which framework to use. Mostly as these frameworks either do way too much or just not enough. Shaunm (and some others in #gnome-hackers) was so nice to convince me that Django was a really good framework. This as I hate frameworks. I want to ignore most of it. My basic needs were CSRF protection (not that I cannot do it myself, but I want to ensure they’ve thought about security), session, something like fastcgi/scgi (the Mango Python stuff needs to run under a different user) and templates etc should be optional.
For the rewrite I’ve decided to use the Bzr mirror. This while still publishing the branch on svn.gnome.org and having the ability to merge both ways (from trunk to django and django to trunk.. at one point). The initial setup for the tools I needed took some time, hopefully this will be resolved soon. This as Mandriva doesn’t have a bzr-svn package yet. I started off with bzr-svn.
Installing bzr-svn is pretty easy (only needed to push to svn.gnome.org, pulling can be done via bzr-mirror):
mkdir -p ~/.bazaar/plugins/ cd ~/.bazaar/plugins bzr branch http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev/ svn
However, that plugin wants the right Subversion version and 1.5 wasn’t packaged for Mandriva Cooker yet. Compiling Subversion failed initially, as it somehow wanted to link to the installed subversion libraries (this while I did not have the 1.4 svn devel package installed). After I figured that out, there was another issue as the Subversion API changed with 1.5. The workaround for now is to remove the assertion on line 944 in subversion/libsvn_ra/ra_loader.c (or wait for the new bzr-svn plugin).
After getting the tools working, the rest is a bit magical. I followed the GNOME Bazaar instructions and branched Mango trunk locally in a django branch. A
bzr push svn+ssh://svn.gnome.org/mango/trunk would be enough to push it back to GNOME (you need to specify the push URL once). However, I wanted a branch in SVN. The
push command currently (?) will not create new branches, but there is a
svn-push which does.
The command I used to create the new ‘upstream’ branch was:
$ bzr svn-push svn+ssh://svn.gnome.org/svn/mango/branches/django
The result from svn-commits-list:
Author: ovitters Date: Sat Jun 21 17:58:09 2008 New Revision: 205 URL: http://svn.gnome.org/viewvc/mango?rev=205&view=rev Log: Try and port the mess to Python using the Django framework. * .bzrignore: Ignore the django directory. * mango/manage.py: Standard Django script to manage the Django project. * mango/models.py: Describes the Database (needs a bit of work). * mango/settings.py: Django settings and the config.xml file. * mango/urls.py: Maps URLs to functions which will be called. * mango/views.py: Handles turning an http request into an http response (application/xml). Added: branches/django/ (props changed) - copied from r204, /trunk/ branches/django/.bzrignore branches/django/mango/ branches/django/mango/manage.py (contents, props changed) branches/django/mango/models.py branches/django/mango/settings.py branches/django/mango/urls.py branches/django/mango/views.py Modified: branches/django/ChangeLog
From above email it is clear it copied (branched) the trunk and not just put new files into that Django branch. The resulting test Django installation works pretty similar as the current PHP Mango version:
Oh, and some way too early screenshots:
Current trunk (PHP)
It seems nice, but that is just because I am sharing the XSLT templates. It doesn’t do anything useful yet. For instance, you can clearly see the missing ‘tabs’ and that it doesn’t filter the account requests. A Django LDAP model would also be nice (has a really nice abstraction for models), but was designed with database in mind unfortunately.