Archives February 2012

Tuesday 28th Febuary 2012

Python Logo

I have been working on this site on and off for a week now and having great fun hacking some python.

As a base for the blog I am using Django. Django is a framwork which is python based and tends to be very modular. The main modules are called applications or apps. There are millions of apps to do different jobs. As a starting point I used Zinnia. Zinnia looks after blogging and includes tagging and CRM type stuff. It was as simple matter of concocting some sqlfu and pulling the data out of mysql and sticking it in postgres. Blog entries are very simple.

Being a bit rusty on Django, I opted to start with stockphoto, a simple gallery app. The ultimate aim is to replicate all of the overall functionality that my current PHP based site has. The original gallery was gallery2 based with over 4000 images in it. There was no way that I was going to upload those again! I ended up doing a lot of hacking on the stockphoto model. They used a number of field names that match postgres keywords like "date" for the creation date field and "desc" for the description field.

The existing gallery2 instance has about 200 galleries with nesting up to 4 levels deep from the root. I was willing to cut this down to just 2 levels. To facilitate this I created the "group" model, which is really just another "gallery" model which lists galleries. That way there are groups in the root, then galleries, then photos. I also customised the admin areas a bit with extra list columns. I wrote two templatetags for stockphoto, first the index page, which shows the list of groups in the sidebar, the second is the random image block. Next on the agenda is to add in tagging.

On a roll now, I decided to tackle the wiki. The existing site had a mediawiki instance with lots of stuff on it which I didn't particulary want to rewrite. Once I worked out how to get the latest revisions of each pages out of the DB, I dumped them all. Next I replicated the schema in postgres and imported the wiki entries. I was then able to create wiki records from the mediawiki data. There was a lot of messing around required, because the wiki module is designed to be used with markdown. I modified the wiki app to incude the wikimarkup python library. I then wrote a new filter which used that instead of the markdown filter.

The mediawiki has a feature currently which allows me to include code and have it syntax hilighted. To replicate this feature I made another filter based on python-pygments. There was all sorts of messing around required because the two filters werent' playing nice together. I found in the end that I needed to run the field through the pygments filter first, then the wikimarkup filter. It's still not perfect. I'm also having trouble with something eating newlines on blog entries code tags.

I also wrote a template tag for the wiki which dumps out a link to the index, as well as a list of featured pages. This involved another model change to include the models.BooleanField() for featuring it.

All of this happend over a week with lots of back and forward and adjustments and tearout-and-reinstall of apps. It's been good fun!


Saturday, 25 February 2012


Kids and speakers are a bad combination. One of the two sub boxes has now laid down it's life for the kids enterainment for 5 minutes. The surrounds are torn and one dome is off. The second sub was rescuable with a bit of vacuum treatment.

Wednesday, 15 February 2012


I have landed a job in internet land! I will be looking after office pcs and their users doing desktop support as well as looking after a few linux boxes serving VPS.

Sunday, 12 February 2012

No Spark

De-Triffidizer has no spark. Obviously they sabotaged the fuel.


This afternoon it poured. Di-Hydrogen Monoxide is clogging my drain...

Daily archives