9 __author__ =
'Wim Lavrijsen (WLavrijsen@lbl.gov)' 11 __all__ = [
'ConfigurableMeta']
17 """The setting of Gaudi component properties needs to be deferred and 18 history of who set what where needs to be collected. This is done 19 by using PropertyProxy descriptors rather than the default ones.""" 23 if 'getType' in dct
and not isinstance(dct[
'getType'], classmethod):
24 dct[
'getType'] = classmethod(dct[
'getType'])
26 if 'setDefaults' in dct
and not isinstance(dct[
'setDefaults'], classmethod):
27 dct[
'setDefaults'] = classmethod(dct[
'setDefaults'])
32 newclass = type.__new__(self, name, bases, dct)
35 newclass.configurables = {}
39 slots = dct.get(
'__slots__')
41 props = [x
for x
in slots
if x[0] !=
'_']
42 propDict = dct.get(
'_propertyDocDct')
44 docString = propDict
and propDict.get(prop)
45 if type(slots) == dict:
49 proxy = PropertyProxy.PropertyProxyFactory(
50 getattr(newclass, prop), docString, default)
52 properties[prop] = proxy
53 setattr(newclass, prop, proxy)
58 bprops = base._properties.copy()
59 bprops.update(properties)
61 except AttributeError:
64 newclass._properties = properties
69 """To Gaudi, any object with the same type/name is the same object. Hence, 70 this is mimicked in the configuration: instantiating a new Configurable 71 of a type with the same name will return the same instance.""" 75 cfg = cls.__new__(cls, *args, **kwargs)
78 if not hasattr(cfg,
'_initok')
or not cfg._initok:
79 cls.__init__(cfg, *args, **kwargs)