Author: bugman Date: Thu Jul 21 11:36:44 2011 New Revision: 13798 URL: http://svn.gna.org/viewcvs/relax?rev=13798&view=rev Log: The execution of the callback functions in the observer objects is now ordered. This is based on the registration order. Modified: branches/gui_testing/status.py Modified: branches/gui_testing/status.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/status.py?rev=13798&r1=13797&r2=13798&view=diff ============================================================================== --- branches/gui_testing/status.py (original) +++ branches/gui_testing/status.py Thu Jul 21 11:36:44 2011 @@ -256,12 +256,15 @@ # The dictionary of callback methods. self._callback = {} + # The list of keys, for ordered execution. + self._keys = [] + def notify(self): """Notify all observers of the state change.""" # Loop over the callback methods and execute them. - for key in self._callback.keys(): + for key in self._keys: self._callback[key]() @@ -275,18 +278,24 @@ """ # Already exists. - if key in self._callback.keys(): + if key in self._keys: raise RelaxError("The observer '%s' already exists." % key) # Add the method to the dictionary of callbacks. self._callback[key] = method + # Add the key to the ordered list. + self._keys.append(key) + def reset(self): """Reset the object.""" # Reinitialise the dictionary of callback methods. self._callback = {} + + # Reinitialise the key list. + self._keys = [] def unregister(self, key): @@ -297,8 +306,11 @@ """ # Does not exist. - if key not in self._callback.keys(): + if key not in self._keys: raise RelaxError("The key '%s' does not exist." % key) # Remove the method from the dictionary of callbacks. self._callback.pop(key) + + # Remove the key for the ordered key list. + self._keys.remove(key)