From: Darren G. <da...@on...> - 2008-11-14 14:43:44
|
I think I figured this out. The it seems to matter what class has the foreign key so special attention needed there. In my case. > class DataRow(SQLObject): > type = StringCol() > data = BLOBCol(length=2**24) > text = UnicodeCol() > row = ForeignKey('ProcessRow') class DataRow(SQLObject): type = StringCol() data = BLOBCol(length=2**24) text = UnicodeCol() row = SingleJoin('ProcessRow') and >class ProcessRow(SQLObject): > path = StringCol() > status = StringCol() > data = SingleJoin('DataRow') > class ProcessRow(SQLObject): path = StringCol() status = StringCol() data = ForeignKey('DataRow') This now works correctly: r = ProcessRow.get(1) print "STATUS:"+r.status print "DATA:"+r.data.type The other direction didn't work when retrieving ProcessRow and referring to DataRow. Maybe the documentation can mention something about this cardinality for One-to-One mapping more clearly. Just a thought! Darren On Fri, 2008-11-14 at 09:08 -0500, Darren Govoni wrote: > Hi, > I read the documentation and it briefly mentions SingleJoin, but gives > no example. > > I tried to use ForeignKey in the referenced class and SingleJoin in the > primary class, but I get this error when retrieving. > > AttributeError: DataRow instance has no attribute 'processRowID' > > My classes are simple. > > class DataRow(SQLObject): > type = StringCol() > data = BLOBCol(length=2**24) > text = UnicodeCol() > row = ForeignKey('ProcessRow') > > class ProcessRow(SQLObject): > path = StringCol() > status = StringCol() > data = SingleJoin('DataRow') > > r = ProcessRow(path='here',status='loading') > datar=DataRow(data=d,type='binary',text='',row=r) > > I'm not sure how to set the 'data' attribute for a ProcessRow since > both classes refer to each other. The DataRow SQL entry has a correct > row_id column set, but when I try to read it back like this, gives > error. > > r = ProcessRow.get(1) > print "STATUS:"+r.status > print "DATA:"+r.data.type <<<<< generates error > > > thank you. > Darren > > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss |