On Thu, Jun 11, 2009 at 3:06 AM, Sam's Lists<samsli...@gmail.com> 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.

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to