Changeset 573
- Timestamp:
- 11/05/07 09:41:05
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/crazycache/dejavu/storage/storememcached.py
r572 r573 541 541 self.cls = cls 542 542 self._key_template = '%s:%s:index(%%s)' % (store.name, cls.__name__) 543 self. _indices = []543 self.indices = [] 544 544 545 545 def add_index(self, *attributes): 546 546 """Add an index over the given attributes.""" 547 547 # Sort them from most-specific (most properties) to least. 548 if attributes not in self. _indices:549 self. _indices.append(attributes)550 self. _indices.sort(lambda x, y: cmp(len(y), len(x)))548 if attributes not in self.indices: 549 self.indices.append(attributes) 550 self.indices.sort(lambda x, y: cmp(len(y), len(x))) 551 551 552 552 def __iter__(self): 553 return iter(self. _indices)553 return iter(self.indices) 554 554 555 555 def key(self, filters): … … 693 693 ident = tuple([getattr(unit, name) 694 694 for name in self.store.primary_keys[self.cls]]) 695 for index in self. _indices:695 for index in self.indices: 696 696 indexcriteria = dict([(k, getattr(unit, k)) for k in index]) 697 697 indexnode = self.get(indexcriteria) or [] … … 704 704 ident = tuple([getattr(unit, name) 705 705 for name in self.store.primary_keys[self.cls]]) 706 for index in self. _indices:706 for index in self.indices: 707 707 indexcriteria = dict([(k, getattr(unit, k)) for k in index]) 708 708 indexnode = self.get(indexcriteria) or []
