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):
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'])