Update introduction docs and examples

This commit is contained in:
Roman Mogilatov 2016-04-04 19:12:21 +03:00
parent 136b562a81
commit 56a597e0a6
4 changed files with 4 additions and 42 deletions

View File

@ -86,12 +86,12 @@ Example
Let's go through next example:
.. literalinclude:: ../../../examples/ioc_demo/car_engine_1.py
.. literalinclude:: ../../../examples/ioc_di_demo/car_engine_1.py
:language: python
``Car`` **creates** an ``Engine`` during its creation. Really? Does it make
more sense then creating an ``Engine`` separatelly and then
**put (inject) it into** ``Car`` when ``Car`` is being created?
.. literalinclude:: ../../../examples/ioc_demo/car_engine_2.py
.. literalinclude:: ../../../examples/ioc_di_demo/car_engine_2.py
:language: python

View File

@ -1,18 +0,0 @@
"""Car & Engine example 1."""
class Engine(object):
"""Example engine."""
class Car(object):
"""Example car."""
def __init__(self):
"""Initializer."""
self.engine = Engine()
if __name__ == '__main__':
car = Car()
assert car.engine is not None

View File

@ -1,18 +0,0 @@
"""Car & Engine example 2."""
class Engine(object):
"""Example engine."""
class Car(object):
"""Example car."""
def __init__(self, engine):
"""Initializer."""
self.engine = engine
if __name__ == '__main__':
car = Car(Engine())
assert car.engine is not None

View File

@ -1,10 +1,8 @@
"""The Code, that uses IoC container."""
from dependency_injector import catalogs
from dependency_injector import providers
from dependency_injector import catalogs, providers
from ioc_example import Service
from ioc_example import Client
from ioc_example import Service, Client
class Components(catalogs.DeclarativeCatalog):