I am trying to run a save/load programm for enthought traits. So the question ist:
What is the easiest way to save and load the traits of HasTraits subclasses to/from a file?
Could anyone help us?
I use the following code. For classes derived by HasTraitsPersistent you can save and load the state of all trait attributes during runtime. Essentially it dumps the state obtained by __getstate__ to a file using the pickle module. Trait attributes created with 'transient=True' are not saved, nor are Properties or Delegates or private attributes starting with underscore. Loading the settings issues change notifications. I derive the filename from the value of the settings_id, needs to be modified by subclasses.
from traits.api import HasTraits, String
import cPickle as pickle
"custom Traits class with methods for loading/saving state"