Injecting a class to be used in another provider #878
Unanswered
foodeater12
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Greetings,
I have some nested containers for a web server in the script below. I want to override the AppServices.*_baseclass object providers from within my main script, but I'm having trouble. It took me several hours to understand the behavior of these providers, and now I don't know where to turn.
`
class AppDatabase(containers.DeclarativeContainer):
pass
`
Here's what I've done so far.
At first, I was inserting the baseclasses into the service singletons like how you see for the Cleanup service: by calling the provider which then returns the class. I was doing this for all the services. This worked because it correctly gives a type to the singleton provider.
With this setup, though, my overrides are completely ignored no matter how I write my main script. Maybe someone could explain this to me?
Anyway, I changed the user/auth/doc service singletons to use baseclass .provided and my overrides finally work, but now the singletons are not instances, but classes, and thus I run into immediate issues when I want to reference self. How can I get these service singletons to give me an instance of whatever the baseclass provider provides?
Hope this makes sense. Thanks for any help!!!!
Beta Was this translation helpful? Give feedback.
All reactions