[EMAIL PROTECTED], el lunes 14 de noviembre a las 17:40 me escribiste:
> 
> Ok, maybe this would be better off in a SQLObject discussion list.
> Sorry about that.
> 
> What I need to know is how to model a self-referencing relationship
> using SQLObject.
> 
> Why? Let's say I want to model a father-son relationship. So I would
> have a table in the database containing person data. Two of the
> atributes of that table should be father and mother, that should
> reference another record of the same table.

I think this should work just fine:

class Person(SQLObject):
        # Unless you want to have a DB with a philosophical
        # problem I guess you should accept None =)
        mother = ForeignKey('Person', default=None)
        father = ForeignKey('Person', default=None)
        # ...

Then:
father = Person(...)
mother = Person(...)
child = Person(..., mother=mother, father=father)

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
 .------------------------------------------------------------------------,
  \  GPG: 5F5A8D05 // F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05 /
   '--------------------------------------------------------------------'
aFR [EMAIL PROTECTED] has quit IRC (Ping timeout)

Reply via email to