Contact: fumanchu@aminus.org

Log in as guest/dejavu to create tickets

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

Changeset 451

Show
Ignore:
Timestamp:
05/16/07 18:25:06
Author:
fumanchu
Message:

Fixed storeram for identifier-less Units.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/storage/storeram.py

    r450 r451  
    6060                unit.cleanse() 
    6161                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) 
    6370            finally: 
    6471                lock.release() 
     
    6976        lock = self._get_lock(unit_cls) 
    7077        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) 
    7283            cache = self._caches[unit_cls] 
    7384            try: 
     
    8192        """Reserve storage space for the Unit.""" 
    8293        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 
    94109     
    95110    def shutdown(self):