Author: bugman Date: Tue Nov 20 23:20:56 2007 New Revision: 3732 URL: http://svn.gna.org/viewcvs/relax?rev=3732&view=rev Log: Merged revisions 3730-3731 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3 ........ r3730 | bugman | 2007-11-20 23:01:11 +0100 (Tue, 20 Nov 2007) | 3 lines Added one additional object to the data storage singleton for testing. ........ r3731 | bugman | 2007-11-20 23:17:56 +0100 (Tue, 20 Nov 2007) | 6 lines Fixed the generic_fns.state.load_state() function. The relax data storage singleton is new being, object by object, recreated from the initial state as cleared by its __reset__ method. ........ Modified: branches/N_state_model/ (props changed) branches/N_state_model/generic_fns/state.py branches/N_state_model/test_suite/unit_tests/generic_fns/test_state.py Propchange: branches/N_state_model/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Tue Nov 20 23:20:56 2007 @@ -1,1 +1,1 @@ -/1.3:1-3692,3695,3697-3713,3715-3719,3721-3728 +/1.3:1-3692,3695,3697-3713,3715-3719,3721-3728,3730-3731 Modified: branches/N_state_model/generic_fns/state.py URL: http://svn.gna.org/viewcvs/relax/branches/N_state_model/generic_fns/state.py?rev=3732&r1=3731&r2=3732&view=diff ============================================================================== --- branches/N_state_model/generic_fns/state.py (original) +++ branches/N_state_model/generic_fns/state.py Tue Nov 20 23:20:56 2007 @@ -28,17 +28,43 @@ from relax_io import open_read_file, open_write_file -def load_state(file=None, dir=None, compress_type=1): +def load_state(file=None, dir_name=None, compress_type=1): """Function for loading a saved program state.""" # Open the file for reading. - file = open_read_file(file_name=file, dir=dir, compress_type=compress_type) + file = open_read_file(file_name=file, dir=dir_name, compress_type=compress_type) # Unpickle the data class. - relax_data_store = load(file) + state = load(file) # Close the file. file.close() + + # Reset the relax data storage object. + relax_data_store.__reset__() + + # Black list of objects. + black_list = ['__weakref__'] + + # Loop over the objects in the saved state, and dump them into the relax data store. + for name in dir(state): + # Skip blacklisted objects. + if name in black_list: + continue + + # Get the object. + obj = getattr(state, name) + + # Place ALL objects into the singleton! + setattr(relax_data_store, name, obj) + + # Loop over the keys of the dictionary. + for key in state.keys(): + # Shift the PipeContainer. + relax_data_store[key] = state[key] + + # Delete the state object. + del state def save_state(file=None, dir=None, force=0, compress_type=1): Modified: branches/N_state_model/test_suite/unit_tests/generic_fns/test_state.py URL: http://svn.gna.org/viewcvs/relax/branches/N_state_model/test_suite/unit_tests/generic_fns/test_state.py?rev=3732&r1=3731&r2=3732&view=diff ============================================================================== --- branches/N_state_model/test_suite/unit_tests/generic_fns/test_state.py (original) +++ branches/N_state_model/test_suite/unit_tests/generic_fns/test_state.py Tue Nov 20 23:20:56 2007 @@ -45,6 +45,9 @@ # Add a single object to the 'orig' data pipe. relax_data_store['orig'].x = 1 + # Add a single object to the storage object. + relax_data_store.y = 'Hello' + def tearDown(self): """Reset the relax data storage object.""" @@ -74,6 +77,7 @@ # Test the contents of the empty singleton. self.assertEqual(relax_data_store.keys(), []) self.assertEqual(relax_data_store.current_pipe, None) + self.assert_(not hasattr(relax_data_store, 'y')) # Load the state. load_state('test')