On Wed, Apr 12, 2006 at 12:09:46PM -0700, Erik Stephens wrote:
> class Report(SQLObject):
> class = ForeignKey('Class')
>
> That's clashing with Python's 'class' keyword. I tried setting this
> after the fact:
>
> setattr(Report, 'class', ForeignKey('Class'))
> setattr(Report.sqlmeta, 'class', ForeignKey('Class'))
You cannot do that becuase columns are magically processed by a
metaclass, and if you do setattr() after the class has been created
metaclass wouldn't process your new attribute and wouldn't make it a proper
column.
> It doesn't look like I can use addColumn() or any other method to add
> a ForeignKey. Any thoughts on how to accomplish this?
Try .addColumn(ForeignKey("Class", name="klass", dbName="class_id")). Or
even
class Report(SQLObject):
klass = ForeignKey('Class', dbName="class_id")
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss