using Axiom Lists in queries

Robert Gravina <[email protected]> Tue, 19 Sep 2006 12:19:32 +0900
Newsgroups gmane.comp.python.quotient.dev
Message-ID <[email protected]>
I'm trying to do a query which involves Axiom Lists  
(axiom.sequence.List). I want to return all items of some type which  
have another item instance on of their Lists.

In a perfect world, the query would look like:

store.query(MyItem, someItemInstance in MyItem.myList)

but that doesn't work :)

I've been trying to do with with joins, such as:

store.query(MyItem, MyItem.myList = List.storeID, List.index 
(someItemInstance))

but that doesn't work neither.

I realise that if I have the List istance I can do "someItemInstance  
in myitem.myList". but I'd like to get a result set with *all*  
MyItems which have someItemInstance in a particular of  List  
attributes. For example, you might want to query for all customers  
who have bought a particular product (i.e. a product is in their list  
of purchased items).

Also in a related problem, I'd like to test if MyItem.myList is a  
List so I can add the required crieria in to my search query, but  
references to Lists and references to any other Item are the same  
class. Is there any way to check for this then?

Thanks again for your help. I've tried reading through comments/ 
docstrings/code in axiom/sequence.py but I'm still lost.

Robert