Thread: [SQLObject] Unknown SQL builtin type error (multiple foreign keys)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Luke O. <lu...@me...> - 2003-09-25 22:19:00
|
I'm thinking this has been mentioned on the list before, but getting an odd error: File "/usr/lib/python2.2/site-packages/SQLObject/SQLBuilder.py", line 126, in sqlRepr raise ValueError, "Unknown SQL builtin type: %s for %s" % \ ValueError: Unknown SQL builtin type: <class 'SQLObject.SQLObject.MetaSQLObject'> for <class 'MyContext.sqlobject.Motivation.Motivation'> When I have two foreignKey's in a table to the same related table Classes look like: class StoryMotivation(CoreObject): monkey = ForeignKey('Motivation') donkey = ForeignKey('Motivation') story = StringCol() class Motivation(CoreObject): name = StringCol() The error happens during the second call to addColumn, and only if I import StoryMotivation before Motivation (otherwise the rogue code below never gets called due to how needSet works). addNeedSet snippet: cls = findClass(setCls, registry=registry) if callable(getattr(obj, attr, None)): getattr(obj, attr)(cls) else: setattr(obj, attr, cls) I'm trying to understand the reason for trying to create an instance of the class in the positive if statement. My code works if I comment that out (ie, if obj.attr already exists, then pass, otherwise set it) or just always set it. But ? - Luke |
From: Ian B. <ia...@co...> - 2003-09-26 04:45:58
|
On Thursday, September 25, 2003, at 05:18 PM, Luke Opperman wrote: > The error happens during the second call to addColumn, and only if I > import > StoryMotivation before Motivation (otherwise the rogue code below > never gets > called due to how needSet works). > > addNeedSet snippet: > cls = findClass(setCls, registry=registry) > if callable(getattr(obj, attr, None)): > getattr(obj, attr)(cls) > else: > setattr(obj, attr, cls) > > I'm trying to understand the reason for trying to create an instance > of the > class in the positive if statement. My code works if I comment that > out (ie, > if obj.attr already exists, then pass, otherwise set it) or just > always set > it. But ? This is so that addNeedSet/setNeedSet allow both callbacks and attribute setting (callbacks being more general). The particular problem here is already fixed in CVS. Ian |