9 __author__ =
'Wim Lavrijsen (WLavrijsen@lbl.gov)' 11 __all__ = [
'ConfigurableMeta' ]
15 """The setting of Gaudi component properties needs to be deferred and 16 history of who set what where needs to be collected. This is done 17 by using PropertyProxy descriptors rather than the default ones.""" 21 if 'getType' in dct
and not isinstance( dct[
'getType' ], classmethod ):
22 dct[
'getType' ] = classmethod( dct[
'getType' ] )
24 if 'setDefaults' in dct
and not isinstance( dct[
'setDefaults' ], classmethod ):
25 dct[
'setDefaults' ] = classmethod( dct[
'setDefaults' ] )
30 newclass = type.__new__( self, name, bases, dct )
33 newclass.configurables = {}
37 slots = dct.get(
'__slots__' )
39 props = [ x
for x
in slots
if x[0] !=
'_' ]
40 propDict = dct.get(
'_propertyDocDct')
42 docString = propDict
and propDict.get(prop)
43 if type(slots) == dict:
47 proxy = PropertyProxy.PropertyProxyFactory( getattr( newclass, prop ), docString, default )
49 properties[ prop ] = proxy
50 setattr( newclass, prop, proxy )
55 bprops = base._properties.copy()
56 bprops.update( properties )
58 except AttributeError:
61 newclass._properties = properties
66 """To Gaudi, any object with the same type/name is the same object. Hence, 67 this is mimicked in the configuration: instantiating a new Configurable 68 of a type with the same name will return the same instance.""" 72 cfg = cls.__new__( cls, *args, **kwargs )
75 if not hasattr(cfg,
'_initok')
or not cfg._initok:
76 cls.__init__( cfg, *args, **kwargs )