| xhac ( @ 2006-12-17 22:32:00 |
mySQLObject
About two month ago I was asked to build a website for internal use, acting as a kind of Electronic Program Guide (EPG) for IPTV. So I started building it using php which was pretty much the only web development tool I knew. As time went on, more and more functionality needed to be added and the website had to communicate with other servers and network elements and stuff, which isn' t so great to do in php. So I decided to switch to turbogears, which is a python web dev framework and which I had long wished to learn.
Using turbogears was super-easy. I was able to convert the whole site in just two days and I ended up with half the code. Once you get the feel for this kind of web development, you just can't go back to embedding code inside your html. Absolutely brilliant.
Then, as I was beginning to get comfortable, I was dully informed that the site would be accessible to "up to 200 pilot users". These news were really disconcerting, for many reasons, not least of which being that it had to be translated in Greek. It turned out that I couldn't for the life of me figure out how to make the turbogears database subsystem, called SQLObject work with database fields that used utf-8 encoding. Many failed attempts later and after realizing that I could never debug SQLObject in time, I decided to reinvent the wheel by writing my own sql object wrapper.
Behold mySQLObject.py
This is probably the most redone project in the history of CS but I wanted to do this since my third year at the university. I wouldn't believe you back then if you told me that you could do this in a day by picking the right programming language, but that's exactly what I did with python.
Its functionality is pretty limited in that it only supports things that I already used in the site (e.x. it only supports fields of strings, integers and boolean). My biggest concern right now is how stable it is. I'm particularly concerned with the stability aspect of things, especially regarding database timeouts and stuff [1]. I'm also pretty sure there are a bunch of security considerations that are not covered, since I did most of the checking and "escaping" in the site code.
Sample usage:
[1]: that's mainly the reason behind the paranoid try: except: of every query. I didn't really have time to actually wait for a real database timeout so I catch everything. This means that you have to remove these checks to debug a faulty query.
PS: The site went up yesterday to a limited number of "friedly" users. I'm keeping my fingers crossed.
About two month ago I was asked to build a website for internal use, acting as a kind of Electronic Program Guide (EPG) for IPTV. So I started building it using php which was pretty much the only web development tool I knew. As time went on, more and more functionality needed to be added and the website had to communicate with other servers and network elements and stuff, which isn' t so great to do in php. So I decided to switch to turbogears, which is a python web dev framework and which I had long wished to learn.
Using turbogears was super-easy. I was able to convert the whole site in just two days and I ended up with half the code. Once you get the feel for this kind of web development, you just can't go back to embedding code inside your html. Absolutely brilliant.
Then, as I was beginning to get comfortable, I was dully informed that the site would be accessible to "up to 200 pilot users". These news were really disconcerting, for many reasons, not least of which being that it had to be translated in Greek. It turned out that I couldn't for the life of me figure out how to make the turbogears database subsystem, called SQLObject work with database fields that used utf-8 encoding. Many failed attempts later and after realizing that I could never debug SQLObject in time, I decided to reinvent the wheel by writing my own sql object wrapper.
Behold mySQLObject.py
This is probably the most redone project in the history of CS but I wanted to do this since my third year at the university. I wouldn't believe you back then if you told me that you could do this in a day by picking the right programming language, but that's exactly what I did with python.
Its functionality is pretty limited in that it only supports things that I already used in the site (e.x. it only supports fields of strings, integers and boolean). My biggest concern right now is how stable it is. I'm particularly concerned with the stability aspect of things, especially regarding database timeouts and stuff [1]. I'm also pretty sure there are a bunch of security considerations that are not covered, since I did most of the checking and "escaping" in the site code.
Sample usage:
from mysqlobject import mySQLObject
class Table(mySQLObject):
. _columns = { "id":"id", "name":"str", "description":"str", "value":"int"}
. _table = "dbtable"
t = Table.selectBy(id = 5)[0]
t.value = 10
t.commit()
for t in Table.select():
. print t.name, t.description
t = Table(name= "asdf", description="desc", value = 10)
t.commit()
for t in Table.select(joinlist = [ "dbtable2" ], sqlwhere= "dbtable2.id = dbtable.value"):
. print t.name
[1]: that's mainly the reason behind the paranoid try: except: of every query. I didn't really have time to actually wait for a real database timeout so I catch everything. This means that you have to remove these checks to debug a faulty query.
PS: The site went up yesterday to a limited number of "friedly" users. I'm keeping my fingers crossed.
Mood: hopeful