this metaclass installs PropertyProxy descriptors for Gaudi properties
More...
this metaclass installs PropertyProxy descriptors for Gaudi properties
The setting of Gaudi component properties needs to be deferred and
history of who set what where needs to be collected. This is done
by using PropertyProxy descriptors rather than the default ones.
Definition at line 22 of file ConfigurableMeta.py.
◆ __call__()
def python.ConfigurableMeta.ConfigurableMeta.__call__ |
( |
|
cls, |
|
|
* |
args, |
|
|
** |
kwargs |
|
) |
| |
To Gaudi, any object with the same type/name is the same object. Hence,
this is mimicked in the configuration: instantiating a new Configurable
of a type with the same name will return the same instance.
Definition at line 95 of file ConfigurableMeta.py.
95 def __call__( cls, *args, **kwargs ):
96 """To Gaudi, any object with the same type/name is the same object. Hence,
97 this is mimicked in the configuration: instantiating a new Configurable
98 of a type with the same name will return the same instance."""
102 cfg = cls.__new__( cls, *args, **kwargs )
105 if cfg
and (
not hasattr(cfg,
'_fInitOk')
or not cfg._fInitOk ):
106 cls.__init__( cfg, *args, **kwargs )
◆ __new__()
def python.ConfigurableMeta.ConfigurableMeta.__new__ |
( |
|
self, |
|
|
|
name, |
|
|
|
bases, |
|
|
|
dct |
|
) |
| |
Definition at line 27 of file ConfigurableMeta.py.
27 def __new__( self, name, bases, dct ):
29 if 'getType' in dct
and not isinstance( dct[
'getType' ], classmethod ):
30 dct[
'getType' ] = classmethod( dct[
'getType' ] )
32 if 'setDefaults' in dct
and not isinstance( dct[
'setDefaults' ], classmethod ):
33 dct[
'setDefaults' ] = classmethod( dct[
'setDefaults' ] )
38 newclass = type.__new__( self, name, bases, dct )
40 if 'AthenaCommon' not in newclass.__module__:
43 meths = {
'getDlls' : 1,
48 for meth, nArgs
in meths.items():
50 f = getattr( newclass, meth )
51 except AttributeError:
52 raise NotImplementedError(
"%s is missing in class %s" % (meth,
str(newclass)))
55 nargcount = f.__code__.co_argcount
56 dflts = f.__defaults__
57 ndefaults = dflts
and len(dflts)
or 0
58 if not nargcount - ndefaults <= nArgs <= nargcount:
59 raise TypeError(
"%s.%s requires exactly %d arguments" % (newclass,meth,nArgs))
62 newclass.configurables = weakref.WeakValueDictionary()
66 slots = dct.get(
'__slots__' )
68 props = [ x
for x
in slots
if x[0] !=
'_' ]
69 propDict = dct.get(
'_propertyDocDct')
71 docString = propDict
and propDict.get(prop)
72 if type(slots)
is dict:
76 proxy = PropertyProxy.PropertyProxyFactory(
77 getattr( newclass, prop ), docString, default )
79 properties[ prop ] = proxy
80 setattr( newclass, prop, proxy )
85 bprops = base._properties.copy()
86 bprops.update( properties )
88 except AttributeError:
91 newclass._properties = properties
The documentation for this class was generated from the following file: