18 __author__ =
'Wim Lavrijsen (WLavrijsen@lbl.gov)' 20 __all__ = [
'ConfigurableMeta']
26 """The setting of Gaudi component properties needs to be deferred and 27 history of who set what where needs to be collected. This is done 28 by using PropertyProxy descriptors rather than the default ones.""" 32 if 'getType' in dct
and not isinstance(dct[
'getType'], classmethod):
33 dct[
'getType'] = classmethod(dct[
'getType'])
35 if 'setDefaults' in dct
and not isinstance(dct[
'setDefaults'],
37 dct[
'setDefaults'] = classmethod(dct[
'setDefaults'])
42 newclass = type.__new__(self, name, bases, dct)
45 newclass.configurables = {}
49 slots = dct.get(
'__slots__')
51 props = [x
for x
in slots
if x[0] !=
'_']
52 propDict = dct.get(
'_propertyDocDct')
54 docString = propDict
and propDict.get(prop)
55 if type(slots) == dict:
59 proxy = PropertyProxy.PropertyProxyFactory(
60 getattr(newclass, prop), docString, default)
62 properties[prop] = proxy
63 setattr(newclass, prop, proxy)
68 bprops = base._properties.copy()
69 bprops.update(properties)
71 except AttributeError:
74 newclass._properties = properties
79 """To Gaudi, any object with the same type/name is the same object. Hence, 80 this is mimicked in the configuration: instantiating a new Configurable 81 of a type with the same name will return the same instance.""" 85 cfg = cls.
__new__(cls, *args, **kwargs)
88 if not hasattr(cfg,
'_initok')
or not cfg._initok:
89 cls.__init__(cfg, *args, **kwargs)