mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-26 11:33:58 +03:00
20 lines
482 B
Python
20 lines
482 B
Python
"""The Code, that uses IoC container."""
|
|
|
|
from dependency_injector import catalogs
|
|
from dependency_injector import providers
|
|
|
|
from ioc_example import Service
|
|
from ioc_example import Client
|
|
|
|
|
|
class Components(catalogs.DeclarativeCatalog):
|
|
"""Catalog of component providers."""
|
|
|
|
service = providers.Factory(Service)
|
|
|
|
client = providers.Factory(Client, service=service)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
client = Components.client() # Application creates Client's instance
|