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"], classmethod):
36 dct[
"setDefaults"] = classmethod(dct[
"setDefaults"])
41 newclass = type.__new__(self, name, bases, dct)
44 newclass.configurables = {}
48 slots = dct.get(
"__slots__")
50 props = [x
for x
in slots
if x[0] !=
"_"]
51 propDict = dct.get(
"_propertyDocDct")
53 docString = propDict
and propDict.get(prop)
54 if isinstance(slots, dict):
58 proxy = PropertyProxy.PropertyProxyFactory(
59 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)