[ZODB-Dev] Finding objects by attribute value?

Leif K-Brooks eurleif at ecritters.biz
Wed Dec 29 01:16:46 EST 2004


If my dbroot['foo'] contains an OOBTree where the values are object 
which have an attribute called "attr", what's the best way to get a list 
of the objects whose "attr" attribute is equal to a certain value, along 
the lines of SQL "SELECT * FROM foo WHERE attr=123"? The most obvious 
method is [obj for obj in dbroot['foo'].iteritems() if obj.attr == 123], 
which gets decent performance for FileStorage, but the performance is 
terrible with ZEO (most likely due to transferring all of those objects 
over the network). What's the correct way to achieve the result I want?


More information about the ZODB-Dev mailing list