Martijn Faassen wrote:
>
> Hey,
>
> [finding related objects]
>
> One way I've come up with is this:
>
>
> m = object_mapper(model)
> for prop in m.iterate_properties:
>      if isinstance(prop, RelationProperty):
>          if prop.direction is ONETOMANY:
>              for related in getattr(model, prop.key):
>                  do_stuff(related)
>
> the other directions still need to be handled though (and recursion).
>
> Would this be a reasonable solution?

it is.  cascade_iterator() is on the right track too, the string argument
you'd send would be a "cascade" type, one of "save-update", "merge",
"delete", etc.  "all" is one of the arguments for "cascade" its true but
internally that is expanded into the individual entries (see
CascadeOptions in sqlalchemy.orm.util).

>
> Regards,
>
> Martijn
>
>
> >
>


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

Reply via email to