python-dependency-injector/docs/introduction/structure.rst

51 lines
1.4 KiB
ReStructuredText
Raw Normal View History

Structure of Dependency Injector
--------------------------------
2016-03-31 21:00:48 +03:00
.. meta::
2016-04-23 15:00:06 +03:00
:keywords: Python,DI,Dependency injection,IoC,Inversion of Control
:description: This article describes "Dependency Injector" framework
components and their interaction between each other.
Providers and containers are the former components of
the framework.
2016-03-31 21:00:48 +03:00
Current section describes *Dependency Injector* main entities and their
interaction between each other.
.. image:: /images/internals.png
:width: 100%
:align: center
2016-06-03 17:33:30 +03:00
There are 2 main entities: providers & containers.
2016-03-31 21:13:28 +03:00
Providers
~~~~~~~~~
2016-06-02 20:27:01 +03:00
Providers are strategies of accessing objects. For example,
2016-03-31 21:13:28 +03:00
:py:class:`dependency_injector.providers.Factory` creates new instance
of provided class every time it is called.
:py:class:`dependency_injector.providers.Singleton` creates provided
2016-06-03 17:33:30 +03:00
instance once and returns it on every next call. Base class is -
2016-03-31 21:13:28 +03:00
:py:class:`dependency_injector.providers.Provider`.
Providers could be:
2016-03-31 21:13:28 +03:00
+ Injected into each other.
+ Overridden by each other.
+ Extended.
2016-03-31 21:13:28 +03:00
Containers
~~~~~~~~~~
2016-03-31 21:13:28 +03:00
Containers are collections of providers. They are used for grouping
2016-03-31 21:13:28 +03:00
of providers by some principles. Base class is -
:py:class:`dependency_injector.containers.DeclarativeContainer`.
Containers could be:
+ Overridden by each other.
+ Copied from each other.
+ Extended.
.. disqus::