I have a reasonably standard hierarchical datastructure which I'm trying
to store in SQL. The basic model looks like this:
class Page(BaseObject):
__tablename__ = "page"
id = schema.Column(types.Integer(), primary_key=True, autoincrement=True)
path = schema.Column(types.Unicode(128), nullable=False, index=True)
children = orm.relation("Page", cascade="all",
collection_class=attribute_mapped_collection("path"))
This works fine. As shown in the basic_tree example you can configure
the children relation with eager loading and a join_depth to load entire
tree structure efficiently.
I want to do the reverse: build a relation which returns a list of all
parents of an object. I figured this would work:
parents = orm.relation("Page", remote_side=[id],
lazy=False, join_depth=5)
That only returns the first parent, not a list of successive parents. Is
it possible to build that parent list like that?
Wichert.
--
Wichert Akkerman <[email protected]> It is simple to make things.
http://www.wiggy.net/ It is hard to make things simple.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---