Hi all,
I've got a question regarding hybrid properties and how to use them
with single table inheritance.
I've got a class hierarchy like this (in semi-pseudo code):
class MyBase(object):
# This has the tablename declared attr, id as primary key, generic
table args etc.
class Person(MyBase, Base):
children = relationship('Children')
class SpecialPerson(Person):
partner = relationship('Person')
Okay, so what I want is for SpecialPerson to return both it's own plus
it's partners children. But, if I add to list of children of a special
person, it only adds to it's local children list. Does that make sense?
This is what I've got now, I'm stabbing around in the dark a little bit,
so I'm hoping for some guidance in the correct way to do this with SQL
Alchemy.
class Person(Mybase, Base):
_children = relationship('Children')
@hybrid_property
def children(self):
return self._children
class SpecialPerson(Person):
partner = relationship('Person')
@hybrid_property
def children(self):
return self._children + self.parter._children
@children.setter
def children(self, value):
self._children = value
Thank you for your time.
Cheers,
James.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.