On Jun 26, 2008, at 11:12 AM, bukzor wrote:
> > Sorry for being a pest, but I've looked at the documentation and > really can't figure this out. If a mapped class is a node of our > graph, where do I find the edges, and how do I get to the next node. the mapper has a method called "iterate_properties" which returns all MapperProperty objects it contains. Each PropertyLoader subclass represents a relation() to another mapper. so you can walk among relations as follows: recursive = set() def walk (cls): print "cls:", cls if cls in recursive: return recursive.add(cls) mapper = class_mapper(cls) for prop in mapper.iterate_properties: if isinstance(prop, PropertyLoader): print "key", prop.key walk(prop.mapper.class_) > > Alternatively, should I do this at the table/sql level rather than the > class/orm level? it depends on what information you're interested in. the use case here seems to be joining among configured relation()s so the ORM level would be better. > How did you yourself learn this? Is there some other reference I'm > overlooking? heres the docs for every API mentioned above: http://www.sqlalchemy.org/docs/05/sqlalchemy_orm.html#docstrings_sqlalchemy.orm_modfunc_class_mapper http://www.sqlalchemy.org/docs/05/sqlalchemy_orm_mapper.html#docstrings_sqlalchemy.orm.mapper_Mapper http://www.sqlalchemy.org/docs/05/sqlalchemy_orm_interfaces.html#docstrings_sqlalchemy.orm.interfaces_MapperProperty http://www.sqlalchemy.org/docs/05/sqlalchemy_orm_properties.html#docstrings_sqlalchemy.orm.properties_PropertyLoader The same documentation can be had by using "pydoc <modulename>", i.e. pydoc sqlalchemy.orm.mapperlib I also think you should consider carefully if you truly need automatic, implicit joining across arbitrarily long paths. Its a feature we explicitly removed for its non-pythonicness and unpredictable behavior. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---