python-dependency-injector/examples/ioc_di_demos/ioc_container_example.py

19 lines
469 B
Python
Raw Normal View History

2016-04-01 10:47:09 +03:00
"""The Code, that uses IoC container."""
2016-03-29 20:17:12 +03:00
2016-04-01 10:47:09 +03:00
from dependency_injector import catalogs
from dependency_injector import providers
from ioc_example import Service
from ioc_example import Client
2016-03-29 20:17:12 +03:00
class Components(catalogs.DeclarativeCatalog):
"""Components catalog."""
service = providers.Factory(Service)
2016-03-31 21:13:28 +03:00
client = providers.Factory(Client, service=service)
2016-03-29 20:17:12 +03:00
if __name__ == '__main__':
2016-03-30 11:45:41 +03:00
client = Components.client() # Application creates Client's instance