Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: how to dynamically add providers to root container #446

Open
Timtam opened this issue Apr 16, 2021 · 0 comments
Open

Question: how to dynamically add providers to root container #446

Timtam opened this issue Apr 16, 2021 · 0 comments

Comments

@Timtam
Copy link

Timtam commented Apr 16, 2021

This is just a question, since i'm unable to figure this out on my own by just reading the docs.
I'm currently trying to rewrite one of my apps to use dependency injector. I have an app context which is known at runtime and needs to be added to the one container I have in my app. The container is declared in an additional file. The entry file then imports the container, sets it up and is ment to add (or override, whatever) the actual app context into the container. It doesn't seem like I can use a dynamic container here, because that one would need to be initialized directly within the main file, correct? I have something like:

The dynamic container examples don't seem to show a way to have a dynamic container as the only container in your application. I'd have trouble typing my code mypy-ready in that case. Could you please tell me how this is possible? I'd imagine that it work via one of two ways, but both seem to not be exactly ment to do this:

  1. Via a dynamic container within a declarative container. I don't want to wrap a container within a container just for one attribute.
  2. Creating an Object provider on a declarative container just to be overridden from the main script. That is possible, but doesn't seem to be the way overriding was ment to be used.
    Thanks for your support.
@Timtam Timtam closed this as completed May 13, 2021
@rmk135 rmk135 reopened this May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants