You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to inject a service from declarative container into sanic handler - but service never get's injected.
container example:
classAppContainer(containers.DeclarativeContainer):
# https://python-dependency-injector.ets-labs.org/providers/inject_self.html__self__=providers.Self()
# This will wire automatically - once you instantiate the containerwiring_config=containers.WiringConfiguration(
packages=[
"xasperuze.routers",
],
)
# Add your container initialization code below# ========================================================================# Application configappconfig: providers.Configuration=providers.Configuration()
# jinja servicesvc_templater: Singleton[Environment] =providers.Singleton(
Jinjia2Factory().get_svc,
app_path=appconfig.app_path,
THEME_REL_PATH=appconfig.THEME_REL_PATH,
SITE_THEME_NAME=appconfig.SITE_THEME_NAME,
ENV_NAME=appconfig.ENV_NAME,
# Injecting the vite loader service as a provider, so we only resolve it when needed.# Otherwise "providers.Self()" wont be availablesvc_vite_loader=svc_vite_loader.provider,
utils=utils,
)
I can pull my service from a container I share via sanic context (ex: templater_from_ctx), but the one I try to inject via Provide[AppContainer.svc_templater] - always comes back as Provider object.
The text was updated successfully, but these errors were encountered:
Trying to inject a service from declarative container into sanic handler - but service never get's injected.
container example:
Injecting service into route in sanic:
I can pull my service from a container I share via sanic context (ex: templater_from_ctx), but the one I try to inject via Provide[AppContainer.svc_templater] - always comes back as Provider object.
The text was updated successfully, but these errors were encountered: