Sorry, I mis-wrote the problem setup. It should be:
class A(SQLObject):
foo = SQLRelatedJoin('E')
bar = ForeignKey('C')
class B(SQLObject):
smell = SQLRelatedJoin('E')
mummy = SQLRelatedJoin('D')
class C(SQLObject):
fine = ForeignKey('D')
class D(SQLObject):
hair = SQLMultipleJoin('C')
bees = SQLRelatedJoin('B')
class E(SQLObject):
moo = SQLRelatedJoin('A')
itch = SQLRelatedJoin('B')
a = A()
On Mon, 2006-11-06 at 19:24 +1000, Stuart Clarke wrote:
> Thanks for the reply, but the solution doesn't work for me.
>
> The problem I posted was actually part of a wider one. Details:
>
> class A(SQLObject):
> foo = SQLRelatedJoin('B')
> bar = ForeignKey('C')
>
> class B(SQLObject):
> smell = SQLRelatedJoin('B')
> mummy = SQLRelatedJoin('D')
>
> class C(SQLObject):
> fine = ForeignKey('D')
>
> class D(SQLObject):
> hair = SQLMultipleJoin('C')
> bees = SQLRelatedJoin('B')
>
> a = A()
>
> OK, my problem is that I want to find all b = B(), such that a.bar.fine
> is in b.mummy AND the intersection of a.foo and b.smell is not an empty
> set.
>
> So, I can get b_global = a.bar.fine.bees which gives me a SelectResults
> of B instances that contains every one I could be interested in, plus
> some more.
>
> I need to select amongst those. Something along these lines:
>
> for my_foo in a.foo:
> b_subset = b_global.filter(my_foo is in B.smell)
>
> I don't mind having the separate b_subsets at this point, although if I
> could aggregate them and specify that each b in b_subsets_aggregate be
> unique, then that would be even better.
>
> So, who's got the chops to help me with this monster? :-)
>
>
> On Mon, 2006-11-06 at 08:40 +0000, [EMAIL PROTECTED] wrote:
> > It sounds like what you want to do is this:
> >
> > class A(SQLObject):
> > foo = RelatedJoin('B')
> >
> > class B(SQLObject):
> > bar = RelatedJoin('A')
> >
> > It's a good idea to keep references in both objects.
> >
> > I believe the join you want goes like this:
> >
> > A.select(A.q.fooID==b.id)
> >
> > See:
> > http://www.sqlobject.org/SQLObject.html#selecting-multiple-objects
> >
> > Hope that helps!
> >
> > -David
> >
> >
> > >
> >
--
Stuart Clarke <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---