Closed alefnula closed 9 years ago
As far as I remember, Django way of loading modules is rather weird. It does not have a well-defined entry point where you can put an injector initialization.
I would do the same as you:
if not inject.is_configured():
inject.configure(ioc.production)
But I do not Django internals, may be, there is a better way.
I will upload a new version to pypi in 5 mins.
I have uploaded a new version to PyPi https://pypi.python.org/pypi/Inject/3.2.0
I added is_configured
and configure_once
. The latter can be called multiple times to configure an injector. It also eliminates race conditions if you try to configure an injector multiple times.
Thanks for an issue.
Wow you're awesome! This was fast! Thanks a lot! :)
Since
django
is (unfortunately) loading some of its modules more than once,inject
is throwing an:inject.InjectorException: Injector is already configured
exception.My current workaround is:
But that's exposing the internals of the
inject
library. I think that it would be cleaner to have something like:But, if you're OK with the "hacky" solution, I'll close the issue.
Thank you for your time :)