On 13-08-11 15:43, Timo wrote: > Hello, sorry if I use the wrong terminology, I just started with > SQLObject and databases in general. > > This is my current class: > class Person(SQLObject): > name = StringCol(notNone=True) > father = StringCol(default='') > mother = StringCol(default='') Sorry about the fuzz, after some more searching and experimenting, I came up with the following which seems to work fine:
class Person(SQLObject): name = StringCol(notNone=True) father = ForeignKey('Person', default=None) mother = ForeignKey('Person', default=None) p1 = Person(name='John') print p1, p1.father, p1.mother p2 = Person(name='Jane') print p2, p2.father, p2.mother p3 = Person(name='Jeff', father=p1, mother=p2) print p3, p3.father, p3.mother Cheers, Timo > > This stores the names for the person's father and mother, but when I > want to access their data, I need to fetch their names first and then > lookup their objects from the database. What I actually want, is that > father and mother are references to their own Person object. Is > something like this possible? I read about SingleJoin/MultipleJoin, > but it always references to another table. > > Cheers, > Timo ------------------------------------------------------------------------------ FREE DOWNLOAD - uberSVN with Social Coding for Subversion. Subversion made easy with a complete admin console. Easy to use, easy to manage, easy to install, easy to extend. Get a Free download of the new open ALM Subversion platform now. http://p.sf.net/sfu/wandisco-dev2dev _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss