Changeset 578
- Timestamp:
- 11/06/07 13:10:51
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/crazycache/dejavu/storage/storememcached.py
r577 r578 198 198 199 199 if not unit.sequencer.valid_id(unit.identity()): 200 if () in indexset .indices:200 if () in indexset: 201 201 # Try to generate an identifier by looking 202 202 # up all units in the global index. … … 261 261 262 262 indexset = self.indexsets[cls] 263 if () in indexset .indices:263 if () in indexset: 264 264 try: 265 265 self.client.add(indexset.key({}), []) … … 295 295 296 296 indexset = self.indexsets[cls] 297 if () in indexset .indices:297 if () in indexset: 298 298 # TODO: recalculate if primary_keys changed 299 299 ci = self.client.get(indexset.key({})) or [] … … 309 309 """If storage structures exist for the given property, return True.""" 310 310 indexset = self.indexsets[cls] 311 if () in indexset .indices:311 if () in indexset: 312 312 clsname = cls.__name__ 313 313 ci = self.client.get(indexset.key({})) … … 337 337 338 338 indexset = self.indexsets[cls] 339 if () in indexset .indices:339 if () in indexset: 340 340 ci = self.client.get(indexset.key({})) or [] 341 341 for id in ci: … … 358 358 359 359 indexset = self.indexsets[cls] 360 if () in indexset .indices:360 if () in indexset: 361 361 ci = self.client.get(indexset.key({})) or [] 362 362 for id in ci: … … 374 374 def cachelen(self, cls): 375 375 indexset = self.indexsets[cls] 376 if () in indexset .indices:376 if () in indexset: 377 377 return len(self.client.get(indexset.key({}))) 378 378 else: … … 382 382 units = [] 383 383 indexset = self.indexsets[cls] 384 if () in indexset .indices:384 if () in indexset: 385 385 for key in self.client.get(indexset.key({})): 386 386 unit = self.client.get(key) … … 395 395 396 396 indexset = self.indexsets[cls] 397 if () in indexset .indices:397 if () in indexset: 398 398 gi_key = indexset.key({}) 399 399 # Delete all units in the global index. … … 589 589 self.cls = cls 590 590 self._key_template = '%s:%s:index(%%s)' % (store.name, cls.__name__) 591 self. indices = []591 self._indices = [] 592 592 593 593 def add_index(self, *attributes): 594 594 """Add an index over the given attributes.""" 595 595 # Sort them from most-specific (most properties) to least. 596 if attributes not in self. indices:597 self. indices.append(attributes)598 self. indices.sort(lambda x, y: cmp(len(y), len(x)))596 if attributes not in self._indices: 597 self._indices.append(attributes) 598 self._indices.sort(lambda x, y: cmp(len(y), len(x))) 599 599 600 600 def __iter__(self): 601 return iter(self. indices)601 return iter(self._indices) 602 602 603 603 def key(self, criteria): … … 764 764 ident = tuple([getattr(unit, name) 765 765 for name in self.store.primary_keys[self.cls]]) 766 for index in self. indices:766 for index in self._indices: 767 767 criteria = [(k, getattr(unit, k)) for k in index] 768 768 indexnode = self.get(criteria) or [] … … 775 775 ident = tuple([getattr(unit, name) 776 776 for name in self.store.primary_keys[self.cls]]) 777 for index in self. indices:777 for index in self._indices: 778 778 criteria = [(k, getattr(unit, k)) for k in index] 779 779 indexnode = self.get(criteria) or []
