I've got a class Keyword that is many to many to itself through a
mapped association table. The association table tracks which keyword
is a parent of through the keywords ids (PK). Please see the pastebin.

http://pastebin.com/774YmjKD

I have been reading the <a href="http://docs.sqlalchemy.org/en/latest/
orm/relationships.html#sqlalchemy.orm.relationship">many to many</a>
and <a href="http://docs.sqlalchemy.org/en/latest/orm/extensions/
associationproxy.html">association proxy</a> documentation but can't
figure out how to get sqlalchemy to do what I want.

With the two association proxy lines commented out I can do the
following with a keyword instance:
keyword.children_relations[0].ckeyword

and that gives me the full keyword object with all columns available,
so all this works:
keyword.children_relations[0].ckeyword.id
keyword.children_relations[0].ckeyword.col2
keyword.children_relations[0].ckeyword.col3

Furthermore you can follow the chain down to get the childs child full
Keyword object like so:
keyword.children_relations[0].ckeyword.children_relations[0].ckeyword

What I am trying to do with the association proxy is simplify the
coding by proxying the association table. I know I am able to proxy a
single column through the association proxy, but what about proxying
the full blooded Keyword object.

So keyword.children_relations[0] would be the full keyword object with
all cols (keyword.children_relations[0].id,
keyword.children_relations[0].col2,
keyword.children_relations[0].col3) attached without having to go
through the association table.

That would make chaining like this possible:
keyword.children_relations[0].children_relations[0]

I've tried to proxy an association proxy as shown in the composite
association proxy documentation but again, I think it's only for a
single column and not the full blooded mapped class instance.

Thanks,
Dave



-- 
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.

Reply via email to