On Thu, Jun 11, 2009 at 3:06 AM, Sam's Lists<sam...@gm...> wrote:
> How can I make sqlObject seemlessly let me refer to columns named in
> the long style just using id?
I think this is more of a Python question than a SQLObject question,
although it may be a little trickier in the SQLObject case because
SQLObject already uses a lot of attribute magic. One approach might
be to just add .id properties to all your classes:
>>> class EventQueueID(object):
... def __init__(self):
... self.EventQueueID = 5
...
>>> e = EventQueueID()
>>> e.id
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'EventQueueID' object has no attribute 'id'
>>> def getid(self):
... return getattr(self, self.__class__.__name__)
...
>>> def setid(self, x):
... return setattr(self, self.__class__.__name__, x)
...
>>> EventQueueID.id = property(fget=getid, fset=setid)
>>> e.id
5
>>> e.id = 7
>>> e.id
7
I don't know if SQLObject has any magic that would break this, but I
think it should work.
|