python-dependency-injector/examples/ioc_di_demos/ioc_container_example.py
2016-04-04 19:12:21 +03:00

18 lines
416 B
Python

"""The Code, that uses IoC container."""
from dependency_injector import catalogs, providers
from ioc_example import Service, Client
class Components(catalogs.DeclarativeCatalog):
"""Components catalog."""
service = providers.Factory(Service)
client = providers.Factory(Client, service=service)
if __name__ == '__main__':
client = Components.client() # Application creates Client's instance