Contact: fumanchu@aminus.org

Log in as guest/dejavu to create tickets

I think I've seen this ORM somewhere before...

Changeset 106

Show
Ignore:
Timestamp:
11/24/05 21:35:24
Author:
fumanchu
Message:

Fixed a failing test for CachingProxy? and BurnedProxy?. Both were retrieving some units from storage that they should not have (because they were testing stale data).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/arenas.py

    r105 r106  
    120120     
    121121    def storage(self, cls): 
     122        """Return the StorageManager which handles Units of the given class.""" 
    122123        found = self._registered_classes.get(cls) 
    123124         
  • trunk/storage/__init__.py

    r105 r106  
    170170        try: 
    171171            cache = self._caches[unitClass] 
    172             seen = {} 
     172            matches = {} 
    173173             
    174174            # Run through our cache first. Hopefully, this will save us 
     
    177177                unit = pickle.loads(pickledUnit) 
    178178                if expr is None or expr.evaluate(unit): 
    179                     seen[id] = unit 
     179                    matches[id] = unit 
    180180             
    181181            if self.nextstore: 
    182182                for unit in self.nextstore.recall(unitClass, expr): 
    183                     if unit.ID not in seen: 
    184                         seen[unit.ID] = unit 
    185183                    if unit.ID not in cache: 
    186184                        # Pickle the Unit to discard extraneous attributes, 
     
    188186                        cache[unit.ID] = pickle.dumps(unit) 
    189187                        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()) 
    192195        finally: 
    193196            lock.release() 
     
    199202        # Don't check .dirty()!! If a unit changes from state A to 
    200203        # to state B, then back again to *exactly* state A, dirty() 
    201         # will be False, and the cached unit will stay in state B. 
     204        # will be False, and the cached data will stay in state B. 
    202205##        if unit.dirty(): 
    203206         
  • trunk/test/zoo_fixture.py

    r105 r106  
    297297         
    298298        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) 
    300303        self.assertEqual(len(zoos), 4) 
    301304        self.assertEqual(matches(lambda x: True), 12) 
  • trunk/units.py

    r105 r106  
    377377        newUnit.sandbox = None 
    378378        return newUnit 
     379     
     380    #                        Pickle data                         # 
    379381     
    380382    def __getstate__(self):