mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-03-03 19:25:48 +03:00
Update application examples to use Resource provider
This commit is contained in:
parent
f7499354ec
commit
d3ec1ef532
|
@ -24,7 +24,7 @@ def main(
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
application = Application()
|
application = Application()
|
||||||
application.config.from_yaml('config.yml')
|
application.config.from_yaml('config.yml')
|
||||||
application.core.configure_logging()
|
application.core.init_resources()
|
||||||
application.wire(modules=[sys.modules[__name__]])
|
application.wire(modules=[sys.modules[__name__]])
|
||||||
|
|
||||||
main(*sys.argv[1:])
|
main(*sys.argv[1:])
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Core(containers.DeclarativeContainer):
|
||||||
|
|
||||||
config = providers.Configuration()
|
config = providers.Configuration()
|
||||||
|
|
||||||
configure_logging = providers.Callable(
|
logging = providers.Resource(
|
||||||
logging.config.dictConfig,
|
logging.config.dictConfig,
|
||||||
config=config.logging,
|
config=config.logging,
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,7 +23,7 @@ def main(
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
container = Container()
|
container = Container()
|
||||||
container.configure_logging()
|
container.init_resources()
|
||||||
container.config.from_ini('config.ini')
|
container.config.from_ini('config.ini')
|
||||||
container.wire(modules=[sys.modules[__name__]])
|
container.wire(modules=[sys.modules[__name__]])
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Container(containers.DeclarativeContainer):
|
||||||
|
|
||||||
config = providers.Configuration()
|
config = providers.Configuration()
|
||||||
|
|
||||||
configure_logging = providers.Callable(
|
logging = providers.Resource(
|
||||||
logging.config.fileConfig,
|
logging.config.fileConfig,
|
||||||
fname='logging.ini',
|
fname='logging.ini',
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user