Changeset 106
- Timestamp:
- 11/24/05 21:35:24
- Files:
-
- trunk/arenas.py (modified) (1 diff)
- trunk/storage/__init__.py (modified) (4 diffs)
- trunk/test/zoo_fixture.py (modified) (1 diff)
- trunk/units.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/arenas.py
r105 r106 120 120 121 121 def storage(self, cls): 122 """Return the StorageManager which handles Units of the given class.""" 122 123 found = self._registered_classes.get(cls) 123 124 trunk/storage/__init__.py
r105 r106 170 170 try: 171 171 cache = self._caches[unitClass] 172 seen= {}172 matches = {} 173 173 174 174 # Run through our cache first. Hopefully, this will save us … … 177 177 unit = pickle.loads(pickledUnit) 178 178 if expr is None or expr.evaluate(unit): 179 seen[id] = unit179 matches[id] = unit 180 180 181 181 if self.nextstore: 182 182 for unit in self.nextstore.recall(unitClass, expr): 183 if unit.ID not in seen:184 seen[unit.ID] = unit185 183 if unit.ID not in cache: 186 184 # Pickle the Unit to discard extraneous attributes, … … 188 186 cache[unit.ID] = pickle.dumps(unit) 189 187 self._recallTimes[unit.ID] = currentTime 190 191 return iter(seen.values()) 188 189 # Only add to matches if it wasn't already in our 190 # cache (because stored units may have stale data). 191 if unit.ID not in matches: 192 matches[unit.ID] = unit 193 194 return iter(matches.values()) 192 195 finally: 193 196 lock.release() … … 199 202 # Don't check .dirty()!! If a unit changes from state A to 200 203 # to state B, then back again to *exactly* state A, dirty() 201 # will be False, and the cached unitwill stay in state B.204 # will be False, and the cached data will stay in state B. 202 205 ## if unit.dirty(): 203 206 trunk/test/zoo_fixture.py
r105 r106 297 297 298 298 zoos = box.recall(Zoo) 299 self.assertEqual(zoos[0].dirty(), False) 299 if isinstance(box.arena.storage(Zoo), dejavu.storage.CachingProxy): 300 self.assertEqual(zoos[0].dirty(), True) 301 else: 302 self.assertEqual(zoos[0].dirty(), False) 300 303 self.assertEqual(len(zoos), 4) 301 304 self.assertEqual(matches(lambda x: True), 12) trunk/units.py
r105 r106 377 377 newUnit.sandbox = None 378 378 return newUnit 379 380 # Pickle data # 379 381 380 382 def __getstate__(self):
