Posts

Showing posts from November, 2009

A simple task queue

I'm working on a little sample framework - really only to keep my sanity and practice my chosen craft - that allows you to string together tasks in a pipeline for processing. To exercise that framework - to flush out the pros and cons of the implementation - I'm writing a sample application. The basic idea is that each task is interested in an event. That event could be the arrival of a file, or the completion of another task etc. To string tasks together, I've created a simple database queue system - as a task completes, it writes to the queue and then other tasks which are interested will see that event and then begin. Tasks complete either successfully (by returning no errors) or unsuccessfully (by returning more than one error). An important concept is to be able to add (or remove) tasks from the pipeline programmatically and without changing the database schema. So, quite simply, when a task completes, that event is written to the queue - but how do we find which event

Rapache on Ubuntu 9.10

I've just now stumbled across Rapache , a useful GUI tool that makes configuring apache easy. I found it by accident in the Ubuntu Software Center, but unfortunately it would freeze while trying to add a new domain. I searched the web for answers, and found a bug report . This didn't specifically reference Ubuntu 9.10 (rather, 9.04) and the file that needed to be patched didn't exist in the given location. I found it easily enough: paul@paul-laptop:~$ sudo find / -name RapacheGui.py[sudo] password for paul: /usr/lib/pymodules/python2.5/RapacheGtk/RapacheGui.py /usr/lib/pymodules/python2.6/RapacheGtk/RapacheGui.py /usr/share/pyshared/RapacheGtk/RapacheGui.py paul@paul-laptop:~$ I edited the last one (/usr/share/pyshared/RapacheGtk/RapacheGui.py) as documented in comment 23 to add the following at line 79: if not Shell.command.ask_password(): sys.exit(1) Note, this line MUST be preceeded by 8 spaces - indentation is important in Python. Now, rapache would prompt for

Tagging with Appengine DataStore

I've been looking into how to implement a tagging mechanism with Appengine (Python). By using a StringListProperty, you can associate a list of tags with an entity. The model would look something like this: from google.appengine.ext import db class Sample(db.Model): name = db.StringProperty(required=True) tags = db.StringListProperty() Now, assuming we want to find the entities tagged with a given word, we can use a query like this: q = db.GqlQuery("SELECT * FROM Sample where tags = :1",'z') If we want to find all entities that have ANY of these tags (OR) we can query with GqlQuery or filter: q = db.GqlQuery("SELECT * FROM Sample where tags in :1",['a','z']) q = domain.Sample.all() q.filter("tags in ", ['b','d']) When we want to find entities with ALL of the given tags: q = db.GqlQuery("SELECT * FROM Sample where tags = :1 and tags = :2",'b','c') q = domain.Sample.all() q.filter(&quo