The Melody experiment

A while ago I started experimenting with a framework for storing structured information in simple text files, with a touch of Python here and there, so the files could act as objects (in the OO sense). I called it Melody. I'm very happy about what came out of the experiment, and I'm actually using it for a few things, but some of the initial design decisions were wrong. They say, "build one to throw away", because you can't really know ahead of time what problems will crop up with a software project. So I'm throwing this one away and starting over. Now is a good time for a brief history of what got built, why, and what went wrong.

The initial motivation for Melody was automating my TODO list. I use quite a few text files to keep track of things and much of the manual moving of stuff between said files could be easily automated, if only I could get them parsed into something. So the syntax for notes started off from there. Adding Python code in the files was a no-brainer; I was thinking of them in terms of objects already, so why not let them have methods? The next step was inheritance, which amounted to saying "this note inherits from that other one", 10 lines of method lookup code, and that's about it.

By this time I was really happy with my little project so I decided to actually use it for something. I keep a log of income and expenditures (in a text file, of course) and I wanted to keep an eye on my balance. So I brought in CherryPy and wrote a simple dispatcher that called note methods to render web pages, using Genshi for HTML templates. This turned out to be pretty easy to implement but a pain to debug, and it made me realise how much polish my codebase still needed.

Next I decided to organize my files collections (music, photos, software kits) into submission. The goal was to index files and synchronize them between machines, using filters to synch only parts of a repository. A few days of intensive hacking, and several hundred lines of code later, I have a working system that can reliably synchronize files. Still needs work (of course) but I'm actually using it.

But then I realised that my parser – a patchwork of regular expressions stepping on each others' toes – was inadequate. So was the web dispatcher, tied with duct tape to the back of CherryPy, with too much code spilled into the notes instead of staying neatly tucked away in the library. Around this time I got really excited about WSGI, and by chance learned about YAML, so I decided to start over, using the good ideas from Melody and keeping everything as simple as possible. The new project is called Cork and it's up on GitHub: http://github.com/alex-morega/cork

Created:
15 Mar 2009, 01:12

Reader Comments

Stas [15 Mar 2009, 05:03]

Congrats, but I couldn't get too much understanding from the plain text, any working instances?

:)

alex [15 Mar 2009, 10:20]

Well, for Melody there's the code at GitHub in http://github.com/alex-morega/ (projects "melody" and "warehouse"); for Cork there's not much to show yet, just a working doctest.

« previous
(Zope2 functional testing with Twill)
next »
(inetd + wsgi)