Changeset 68
- Timestamp:
- 03/14/05 19:13:04
- Files:
-
- trunk/__init__.py (modified) (2 diffs)
- trunk/storage/sockets.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/__init__.py
r67 r68 599 599 600 600 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.""" 602 602 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): 605 604 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.""" 611 609 for cls in self._registered_classes: 612 610 store = self.storage(cls) 613 611 if old_store is None or old_store is store: 614 612 self.migrate_class(cls, new_store) 613 if not copy_only: 614 self._registered_classes[cls] = new_store 615 615 616 616 … … 761 761 u" classes in disparate stores.") 762 762 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. 763 768 for unitset in store.multirecall(*pairs): 764 769 confirmed = True trunk/storage/sockets.py
r67 r68 40 40 def destream(unit, data): 41 41 # 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) 43 48 cls = unit.__class__ 44 49 for key in cls.properties():
