Open nachobacanful opened 4 years ago
class Child(Object):
def __init__(self, stuff ..., **kwargs):
if "_backend" in kwargs:
self._backend = kwargs.pop("_backend")
plugin = Attribute('plugin', plugin, _backend=self._backend)
....
super().__init__('cybexp_input_config', data, **kwargs)
we dont want to add _backend
to the child __init__
signature because we will force the programmer to specify a _backend
or we will be forced to add a default value to the child signature, by using the kwargs we allow the child class to inherit the default value from the parent.
The above solution works
by the time we set the correct backend is set the parent backend has already been used.
Affected
children of Objects:
Example
When creating a
User
instance we can do the following:the issue is that all the attributes/events/etc will use the wrong backend. since
self._backend
is defined by the parent class it exists and we can use to create tahoe objects and attributes. for example line 17-22 in the image above. it sets these attributes\' backend to beself.backend
. the problem is that this backend is not the one specified inUser(_backend=b)
because this is not set until later in theUser.__init__()
by thesuper().__init__()
(line24). so by the time we set the correct backend is set the parent backend has already been used.