How it works
Kefir is a probiotic food that helps the body heal itself by working to restore the natural balance of 'gut fauna' in the stomach and intestines. Many drinkers report an initial detoxification week where they feel sick and have some cold or flu like symptoms. This is really just the body cleaning itself out, including alot of nasty bacteria getting nastier as they die slowly in the intestines and release some of the toxins they were holding. However with some patience, many kefir drinkers also report mood increases (they have more of them), a general sense of well being, and finally catching that lucky charms fellow. If you're interested in how this program works, that's another story.
Kefir is fairly simple. It has three major components. The first is a Glade File parser, that obviously breaks down a glade file into the important parts. Since you, the developer, are mainly concerned with the Window as a whole, and the signal callbacks you declared in Glade, it picks them out, and stores them internally. The second part is a Kefir Parser. This, slightly less than obviously, breaks down a Kefirized application into it's constituent parts, and stores that in a really weird tree I call a Dictionary Tree. See below how that works. This parser was written in the Toy Parser Generator format, and uses of course the Toy Parser Generator, written by Christophe DeLord. TPG is a lightweight LR parser written in TPG, but implemented in python. Parser people are crazy.
In a stroke of bad planning, the Glade File parser also accepts this dictionary tree, and can output a new Kefirized app. It essentially plans out what the file will look like, what objects and methods should it have, and then checks to see if any methods were already filled out previously. If so, it inserts all the older code in place, and spits back out a full Kefirized app.
What is important for the developer, that is you, are the tags surrounding each function and class. They may look like this:
#@-- callback Mainwindow.onCommitChangesAction { def onCommitChangesAction(self, widget, args=[]): self.saveComments() self.saveConfig(self.configFile) self.model.flush() #@-- callback Mainwindow.onCommitChangesAction }It's important not to edit anything outside of a tag block, although, there is a place in every file for custom functions, and in every class for custom methods.
The third part is the runtime module SimpleGladeApp.py. It is generated the first time kefir is run, and must be included with the program when distributed. It's a clever wrapper around libglade written by Sandino Moreno Flores, that allows you to access a window or any other top level structure in glade as a single object. It also has methods to gain access to any widget inside. Finally, and most importantly, it hooks up all the signals declared in glade to the signals in your custom class. Because of this file, all you have to do is write the 'control code' everytime a signal is recieved in your app.
As a side note, SimpleGladeApp.py is released as LGPL. This means you can in fact use Kefir to write a program under any liscense you want as long as you follow the rules for the LGPL. Although, closed source Python is not a very common thing anyways, though it's nice to have your bases covered.
Dictionary Trees
When I was cobbling this all together, I decided it would be best to represent the parsed kefirized apps as a tree. Since the order of the children weren't vital, and the would all be referenced by name anyways, I figured the fastest way to access it's members would be with a hashtable. Since python hashtables don't allow you to put in any description describing the table itself without using another structure, I decided to put the parents on the same level as the children. Therefore a node is simply another hash table, and a leaf is a different object. In order to get the metadata of a parent, access the 'leaf' with the same name as the parent, but stored in the map describing the children. The only limitation is this tree is an Ashkenazi Jewish Family Tree, i.e. the children cannot share the same name as their parents. (This is not entirely true, whereas Ashkenazi Jews never name their children after any living relative. But let's keep things simple, ok?)
Menu
News
June 16, 2006 Kefir PR3 Released! With a tutorial! June 13, 2006 New and improved, the website uses the psychadelic powers of PHP! Click anywhere and see dragons! June 9, 2006 Well, We've managed to get a website out. You're looking at it! Click anywhere!