[SQLObject] help with circular foreign keys?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: inhahe <in...@gm...> - 2009-05-12 07:08:28
|
sorry if there was something in the documentation i should have understood, but i'm having this problem the code: class Pics(SQLObject): itemid = IntCol() picdata = BLOBCol() thumbnail = ForeignKey("Thumbs", cascade='null') try: Pics.createTable() print "Created table Pics" except dberrors.OperationalError: pass class Thumbs(SQLObject): itemid = IntCol() pic = ForeignKey("Pics", cascade=True) picdata = BLOBCol() try: Pics.createTable() print "Created table Pics" except dberrors.OperationalError: pass the error: KeyError: 'No class Thumbs found in the registry [default] (these classes exist: Log, Pics, RegisterSessions, SQLObject, Sessions, Users)' that list is a list of all the tables created before i got to that point, so i assume the error is that Thumbs must be registered before I can make a foreign key to it, but then if I put Thumbs before Pics, Pics wouldn't be registered yet when I try to make a foreign key to that. how do i solve this? sorry if the answer is supposed to be obvious =p |