Author: bugman Date: Wed Jul 13 19:20:35 2011 New Revision: 13599 URL: http://svn.gna.org/viewcvs/relax?rev=13599&view=rev Log: The pipe switching observing object is now located in the relax status singleton. The location is currently status.observers.pipe_switch. Modified: branches/gui_testing/generic_fns/pipes.py branches/gui_testing/gui/analyses/__init__.py branches/gui_testing/status.py Modified: branches/gui_testing/generic_fns/pipes.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/generic_fns/pipes.py?rev=13599&r1=13598&r2=13599&view=diff ============================================================================== --- branches/gui_testing/generic_fns/pipes.py (original) +++ branches/gui_testing/generic_fns/pipes.py Wed Jul 13 19:20:35 2011 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2004, 2006-2011 Edward d'Auvergne # +# Copyright (C) 2004-2011 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -32,6 +32,7 @@ from dep_check import C_module_exp_fn, scipy_module from observer import Observer from relax_errors import RelaxError, RelaxNoPipeError, RelaxPipeError +from status import Status; status = Status() # List of valid data pipe types. @@ -141,9 +142,8 @@ ds.current_pipe = None __builtin__.cdp = None - # Register the switch. - switch_obj = Pipe_switch_observer() - switch_obj.notify_observers() + # Notify observers that the switch has occurred. + status.observers.pipe_switch.notify_observers() def display(): @@ -262,9 +262,8 @@ ds.current_pipe = pipe_name __builtin__.cdp = get_pipe() - # Register the switch. - switch_obj = Pipe_switch_observer() - switch_obj.notify_observers() + # Notify observers that the switch has occurred. + status.observers.pipe_switch.notify_observers() def test(pipe_name=None): @@ -288,21 +287,3 @@ # Test if the data pipe exists. if pipe_name not in ds: raise RelaxNoPipeError(pipe_name) - - - -class Pipe_switch_observer(Observer): - """Observer and singleton object for pipe switches.""" - - # Class variable for storing the class instance. - instance = None - - def __new__(self, *args, **kargs): - """Replacement function for implementing the singleton design pattern.""" - - # First initialisation. - if self.instance is None: - self.instance = object.__new__(self, *args, **kargs) - - # Already initialised, so return the instance. - return self.instance Modified: branches/gui_testing/gui/analyses/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/analyses/__init__.py?rev=13599&r1=13598&r2=13599&view=diff ============================================================================== --- branches/gui_testing/gui/analyses/__init__.py (original) +++ branches/gui_testing/gui/analyses/__init__.py Wed Jul 13 19:20:35 2011 @@ -81,9 +81,8 @@ status.analyses = Status_container() # Register the page switch method for pipe switches. - switch_obj = pipes.Pipe_switch_observer() self.name = 'notebook page switcher' - switch_obj.register_observer(self.name, self.pipe_switch) + status.observers.pipe_switch.register_observer(self.name, self.pipe_switch) def analysis_data_loop(self): Modified: branches/gui_testing/status.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/status.py?rev=13599&r1=13598&r2=13599&view=diff ============================================================================== --- branches/gui_testing/status.py (original) +++ branches/gui_testing/status.py Wed Jul 13 19:20:35 2011 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2010 Edward d'Auvergne # +# Copyright (C) 2010-2011 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -27,6 +27,9 @@ from re import search import sys from threading import Lock + +# relax module imports. +from observer import Observer class Status(object): @@ -79,6 +82,20 @@ self.skipped_tests = [] """The skipped tests list. Each element should be a list of the test case name, the missing Python module, and the name of the test suite category (i.e. 'system' or 'unit').""" + # Set up the observer objects. + self._setup_observers() + + + def _setup_observers(self): + """Set up all the observer objects.""" + + # A container for all the observers. + self.observers = Status_container() + + # The observer object for pipe switches. + self.observers.pipe_switch = Observer() + + class Status_container: """The generic empty container for the status data."""