Re: using axiom.dependency for powerups in queries

Robert Gravina <[email protected]> Tue, 11 Mar 2008 19:33:05 +0900
Newsgroups gmane.comp.python.quotient.dev
Message-ID <[email protected]>
On Mar 11, 2008, at 1:52 AM, Tristan Seligmann wrote:

> * Robert Gravina <[email protected]> [2008-03-10 13:12:58 +0900]:
>
>> #    c = s.findFirst(Person, AND(Contractor.installedOn ==  
>> Person.storeID, Contractor.rate ==  Decimal("40")))
>> #    assert c is p
>
> I would probably write this query something like:
>
> contractor = s.findFirst(Contractor, Contractor.rate == Decimal("40"))
> assert installedOn(contractor) is p

Great, thanks! That works, but I'm really thinking of the case where  
I'd be using store.query to return a list of people... I just used  
findFirst in this example because there was only one. E.g., for many  
Person:

     for person in s.query(Contractor, Contractor.rate == Decimal 
("40")):
         p = dependency.installedOn(person)

works, as does:

     people = [dependency.installedOn(person) for person in s.query 
(Contractor, Contractor.rate == Decimal("40"))]

but is there a way to get the query to return Person instead of  
Contractor?

Robert