Open pisua opened 6 years ago
I have troubles replicating the issue, you can find my test bundle below.
It creates 3 components providing dummy services, a GrandParent
class (not a factory) declaring a single @Requires
, inherited by a Parent
component factory with its own requirement, itself inherited by the Child
component factory.
Even when commenting the @Requires
(toto
) of Parent
, the child still has the other two requirements injected.
Do you have a sample code to see what happens ? Which version of iPOPO are you using ?
from pelix.ipopo.decorators import (
ComponentFactory,
Requires,
Instantiate,
Validate,
Provides,
)
from pelix.framework import create_framework
@ComponentFactory()
@Provides("foo")
@Instantiate("foo")
class Foo:
pass
@ComponentFactory()
@Provides("bar")
@Instantiate("bar")
class Bar:
pass
@ComponentFactory()
@Provides("baz")
@Instantiate("baz")
class Baz:
pass
@Requires("tutu", "baz")
class GrandParent:
def __init__(self):
self.tutu = None
@ComponentFactory()
@Requires("toto", "foo")
@Instantiate("parent")
class Parent(GrandParent):
def __init__(self):
super().__init__()
self.toto = None
@Validate
def validate(self, ctx):
print("Parent ## tutu=", self.tutu, "toto=", self.toto)
@ComponentFactory()
@Requires("titi", "bar")
@Instantiate("child")
class Child(Parent):
def __init__(self):
super().__init__()
self.titi = None
@Validate
def validate(self, ctx):
print(
"Child ## tutu=", self.tutu, "toto=", self.toto, "titi=", self.titi
)
Here is a sample output:
Child ## tutu= <check.Baz object at 0x00000209D2BB2940> toto= <check.Foo object at 0x00000209D2BED320> titi= <check.Bar object at 0x00000209D2BB2978>
Parent ## tutu= <check.Baz object at 0x00000209D2BB2940> toto= <check.Foo object at 0x00000209D2BED320>
I'll see to provide you asap the code sample.
No news on this issues and I couldn't reproduce it. Moving it to milestone 0.8.1 waiting for more details.
As property decorator that can be inherit from an super class. it cloud be interesting to inherit @Requires decorator from a superclass to prevent to set it to the all child classes if they all have the same require instance to be injected unlike ipojo