-
- Notifications
You must be signed in to change notification settings - Fork 338
Closed
Labels
Description
Hi,
I'd like to use mutiple containers like in the example: https://python-dependency-injector.ets-labs.org/examples/application-multiple-containers.html
But I have the following problem, my factories use the first configuration value and ignore the new values.
If I use a single container it works fine.
Here is an example that re-create the problem:
from dependency_injector import containers, providers class Core(containers.DeclarativeContainer): config = providers.Configuration() greetings = providers.Factory(str, config.greeting) class Application(containers.DeclarativeContainer): config = providers.Configuration() core = providers.Container( Core, config=config, ) greetings = providers.Factory(str, config.greeting) if __name__ == '__main__': container = Core() container.config.set("greeting", "Hello World") assert container.greetings() == "Hello World" container.config.set("greeting", "Hello Bob") assert container.greetings() == "Hello Bob" container = Application() container.config.set("greeting", "Hello World") assert container.greetings() == "Hello World" assert container.core.greetings() == "Hello World" container.config.set("greeting", "Hello Bob") assert container.greetings() == "Hello Bob" # Last one will fail, value is still "Hello World" assert container.core.greetings() == "Hello Bob"
I'd appreciate if you could tell me why the first value set can be seen by the Core container but subsequent updates are ignored
Thanks