Thanks a lot, it works perfectly. On a matter of using 0.8 - is it allready 
stable enough to switch to? (My projects are nothing critical, but still...)

On Wednesday, December 12, 2012 6:11:55 PM UTC+2, Michael Bayer wrote:
>
>
> On Dec 12, 2012, at 4:27 AM, AlexVhr wrote:
>
> Hi all.
> I need to find out if a certain class has one-to-many relations to other 
> classes, and what exactly this classes are. Something like this:
> I'm kind of half way there:
>
>
> def findRelatedClasses(cls):
>
>     #iterate cls.__dict__, find a class member with
>
>     #property.direction.name == ‘ONETOMANY’.
>
>     #Now, to find out which class it links to…
>
>  
>
> findRelatedClasses(Parent) should return a list of type objects ([Child] 
> in this instance). Any ideas how to do that? Thanks!
>
>
> property.mapper is the target Mapper and mapper.class_ is the class which 
> is mapped.
>
> in 0.7 you want to use class_mapper(cls).iterate_properties() to get at 
> MapperProperty, don't bother with __dict__ (and even then I'd be using 
> dir()/getattr() to deal with descriptors).
>
> There's an improved introspection interface in 0.8, see: 
> http://docs.sqlalchemy.org/en/rel_0_8/core/inspection.html , you'd use 
> inspect(cls).relationships.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/L_y3F-9AOWAJ.
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