| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 2010

# __init__.py

Go to the documentation of this file.

    00001 import os, sys
    00002
    00003 __configurables_module_fullname__ = __name__ + '.Configurables'
    00004 __ignore_missing_configurables__ = False
    00005
    00006 ## Small class that allows to access all the configurables as attributes of the
    00007 #  instance.
    00008 #  Used as module to allow code like
    00009 #  @code
    00010 #  from Gaudi.Configuration import Configurables
    00011 #  Configurables.MyConf()
    00012 #  @endcode
    00013 class _ConfigurablesModule(object):
    00014     ## Initializes the instance
    00015     def __init__(self):
    00016         ## If set to true, does not raise an AttributeError if the configurable is not found.
    00017         self.ignoreMissingConfigurables = False
    00018
    00019     def __getattr__(self, name):
    00020         # trigger the load of the configurables database
    00021         from Gaudi.Configuration import confDbGetConfigurable, cfgDb
    00022         # return value
    00023         retval = None
    00024         # handle the special cases (needed for modules): __all__, __path__
    00025         if name == "__all__":
    00026             retval = cfgDb.keys()
    00027         elif name == "__path__":
    00028             retval == None
    00029         elif name in cfgDb.keys(): # ignore private names
    00030             retval = confDbGetConfigurable(name)
    00031         elif self.ignoreMissingConfigurables:
    00032             import logging
    00033             logging.getLogger(__configurables_module_fullname__).warning('Configurable class %s not in database', name)
    00034         else:
    00035             # We raise an AttributeError exception if the configurable could not be found
    00036             # to respect the Python semantic.
    00037             raise AttributeError("module '%s' does not have attribute '%s'" % (__configurables_module_fullname__, name))
    00038         return retval
    00039
    00040 # install the facade module instance as a module
    00041 Configurables = _ConfigurablesModule()
    00042 sys.modules[__configurables_module_fullname__] = Configurables