Oops, store the serialized Experiment in state not self.info.
authorW. Trevor King <wking@drexel.edu>
Sat, 21 Aug 2010 16:01:19 +0000 (12:01 -0400)
committerW. Trevor King <wking@drexel.edu>
Sat, 21 Aug 2010 16:01:19 +0000 (12:01 -0400)
hooke/curve.py

index af572f3cfd1a6794657dc9aca9272e9bbd094e95..75fbf75ce2f394bb9d03dcf39e29ca69bf0419ef 100644 (file)
@@ -191,17 +191,18 @@ class Curve (object):
             self.name = os.path.basename(path)
 
     def __getstate__(self):
-        state = dict(self.__dict__)
+        state = dict(self.__dict__)      # make a copy of the attribute dict.
+        state['info'] = dict(self.info)  # make a copy of the info dict too.
         del(state['_hooke'])
         dc = state['command_stack']
         if hasattr(dc, '__getstate__'):
             state['command_stack'] = dc.__getstate__()
-        if self.info.get('experiment', None) != None:
-            e = self.info['experiment']
-            assert isinstance(e, experiment.Experiment)
+        if state['info'].get('experiment', None) != None:
+            e = state['info']['experiment']
+            assert isinstance(e, experiment.Experiment), type(e)
             # HACK? require Experiment classes to be defined in the
             # experiment module.
-            self.info['experiment'] = e.__class__.__name__
+            state['info']['experiment'] = e.__class__.__name__
         return state
 
     def __setstate__(self, state):
@@ -213,7 +214,7 @@ class Curve (object):
             elif key == 'info':
                 if 'experiment' not in value:
                     value['experiment'] = None
-                else:
+                elif value['experiment'] != None:
                     # HACK? require Experiment classes to be defined in the
                     # experiment module.
                     cls = getattr(experiment, value['experiment'])