Contact: fumanchu@aminus.org

Log in as guest/dejavu to create tickets

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

Changeset 68

Show
Ignore:
Timestamp:
03/14/05 19:13:04
Author:
fumanchu
Message:

1. Some changes to Arena.migrate behavior, now with copy_only.
2. sandbox.multirecall is broken--deprecated until a fix is made.
3. Better error-handler in storage.sockets.destream.

Files:

Legend:

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

    r67 r68  
    599599     
    600600    def migrate_class(self, cls, new_store): 
    601         """migrate_class(cls, new_store). Copy all units of cls to new store.""" 
     601        """migrate_class(cls, new_store). Copy all units of cls to new_store.""" 
    602602        new_store.create_storage(cls) 
    603         box = self.new_sandbox() 
    604         for unit in box.recall(cls): 
     603        for unit in self.new_sandbox().recall(cls): 
    605604            new_store.reserve(unit) 
    606         self._registered_classes[cls] = new_store 
    607         box.flush(cls) 
    608      
    609     def migrate(self, new_store, old_store=None): 
    610         """migrate(new_store, old_store=None). Copy all units (of old_store) to new store.""" 
     605            new_store.save(unit, True) 
     606     
     607    def migrate(self, new_store, old_store=None, copy_only=False): 
     608        """migrate(new_store, old_store=None). Copy all units (of old_store) to new_store.""" 
    611609        for cls in self._registered_classes: 
    612610            store = self.storage(cls) 
    613611            if old_store is None or old_store is store: 
    614612                self.migrate_class(cls, new_store) 
     613                if not copy_only: 
     614                    self._registered_classes[cls] = new_store 
    615615 
    616616 
     
    761761                                 u" classes in disparate stores.") 
    762762         
     763        # This is broken. If a filter expr is supplied, then the store may 
     764        # not return rows which our cache would, and those won't be included 
     765        # in the resultset. If you're using multirecall with no expr's, or 
     766        # in read-only scripts, it should be OK for now. But if you mutate 
     767        # Units and then call multirecall, expect inconsistent results. 
    763768        for unitset in store.multirecall(*pairs): 
    764769            confirmed = True 
  • trunk/storage/sockets.py

    r67 r68  
    4040def destream(unit, data): 
    4141    # data will be a pickled dictionary of properties for a unit. 
    42     attrdict = pickle.loads(data) 
     42    try: 
     43        attrdict = pickle.loads(data) 
     44        if not isinstance(attrdict, dict): 
     45            raise TypeError(attrdict) 
     46    except pickle.UnpicklingError: 
     47        raise TypeError(data) 
    4348    cls = unit.__class__ 
    4449    for key in cls.properties():