On Mon, Mar 10, 2008 at 3:12 AM, Oleg Broytmann <phd@phd.pp.ru> wrote:
On Sun, Mar 09, 2008 at 08:52:28PM -0700, Daniel Fetchinson wrote:
> class zoo( SQLObject ):
>     cages = MultipleJoin( 'cage' )
>
> class cage( SQLObject ):
>     zoo = ForeignKey( 'zoo' )
>     animals = MultipleJoin( 'animal' )
>     properties = RelatedJoin( 'property' )
>
> class animal( SQLObject ):
>     cage = ForeignKey( 'cage' )
>     properties = RelatedJoin( 'property' )
>
> class property( SQLObject ):
>     animals = RelatedJoin( 'animal' )
>     cages = RelatedJoin( 'cage' )
>
>
> What would be the select call for selecting all properties for a given
> zoo instance?

  SQLObject cannot automagically construct such a comple SQL query. You
can do it in Python:

z = zoo.get(id)
zoo_properties = []
for c in z.cages:
  for a in c.animals:
     for p in a.properties:
        zoo_properties.append(p)




Thanks, this is the approach I had so far, but I thought some clever join construction would do it if done right.

Cheers,
Daniel