Update IoC and DI demos

This commit is contained in:
Roman Mogilatov 2016-05-29 17:33:31 +03:00
parent 83bbbd2be7
commit b2d5819da7
3 changed files with 5 additions and 5 deletions

View File

@ -10,7 +10,7 @@ class Car(object):
def __init__(self):
"""Initializer."""
self.engine = Engine()
self.engine = Engine() # Engine is a "hardcoded" dependency
if __name__ == '__main__':

View File

@ -10,7 +10,7 @@ class Car(object):
def __init__(self, engine):
"""Initializer."""
self.engine = engine
self.engine = engine # Engine is an "injected" dependency
if __name__ == '__main__':

View File

@ -1,14 +1,14 @@
"""Example of inversion of control container for Car & Engine example."""
from dependency_injector import catalogs
from dependency_injector import containers
from dependency_injector import providers
from car_engine_ioc import Car
from car_engine_ioc import Engine
class Components(catalogs.DeclarativeCatalog):
"""Catalog of component providers."""
class Components(containers.DeclarativeContainer):
"""IoC container of component providers."""
engine = providers.Factory(Engine)