Changeset 451
- Timestamp:
- 05/16/07 18:25:06
- Files:
-
- trunk/storage/storeram.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/storage/storeram.py
r450 r451 60 60 unit.cleanse() 61 61 cache = self._caches[unit.__class__] 62 cache[unit.identity()] = pickle.dumps(unit) 62 if unit.identifiers: 63 # Replace the entire value to get around writeback issues. 64 # See the docs on "shelve" for more info. 65 key = unit.identity() 66 else: 67 # This class has no identifiers, so hash the whole dict. 68 key = pickle.dumps(unit._properties) 69 cache[key] = pickle.dumps(unit) 63 70 finally: 64 71 lock.release() … … 69 76 lock = self._get_lock(unit_cls) 70 77 try: 71 id = unit.identity() 78 if unit.identifiers: 79 id = unit.identity() 80 else: 81 # This class has no identifiers, so hash the whole dict. 82 id = pickle.dumps(unit._properties) 72 83 cache = self._caches[unit_cls] 73 84 try: … … 81 92 """Reserve storage space for the Unit.""" 82 93 unit_cls = unit.__class__ 83 lock = self._get_lock(unit_cls) 84 try: 85 cache = self._caches[unit_cls] 86 if not unit.sequencer.valid_id(unit.identity()): 87 unit.sequencer.assign(unit, cache.keys()) 88 # Pickle the Unit to discard extraneous attributes, 89 # and avoid identity issues. 90 cache[unit.identity()] = pickle.dumps(unit) 91 finally: 92 lock.release() 93 unit.cleanse() 94 if unit_cls.identifiers: 95 lock = self._get_lock(unit_cls) 96 try: 97 cache = self._caches[unit_cls] 98 if not unit.sequencer.valid_id(unit.identity()): 99 unit.sequencer.assign(unit, cache.keys()) 100 # Pickle the Unit to discard extraneous attributes, 101 # and avoid identity issues. 102 cache[unit.identity()] = pickle.dumps(unit) 103 finally: 104 lock.release() 105 unit.cleanse() 106 else: 107 # This class has no identifiers, so skip reserve and wait for save. 108 pass 94 109 95 110 def shutdown(self):
