2016-06-06 11:26:53 +03:00
|
|
|
Specialization of containers
|
|
|
|
----------------------------
|
2015-12-15 17:49:07 +03:00
|
|
|
|
2016-06-03 00:48:06 +03:00
|
|
|
.. currentmodule:: dependency_injector.containers
|
2015-12-15 17:49:07 +03:00
|
|
|
|
2016-06-06 11:26:53 +03:00
|
|
|
:py:class:`DeclarativeContainer` could be specialized for any kind of needs
|
|
|
|
via declaring its subclasses.
|
2015-12-15 17:49:07 +03:00
|
|
|
|
2016-06-06 11:26:53 +03:00
|
|
|
One of such `builtin` features is a limitation for providers type.
|
2015-12-15 17:49:07 +03:00
|
|
|
|
2016-06-06 11:26:53 +03:00
|
|
|
Next example shows usage of this feature with :py:class:`DeclarativeContainer`
|
2015-12-15 17:49:07 +03:00
|
|
|
in couple with feature of :py:class:`dependency_injector.providers.Factory`
|
|
|
|
for limitation of its provided type:
|
|
|
|
|
2016-06-06 11:26:53 +03:00
|
|
|
.. literalinclude:: ../../examples/containers/declarative_provider_type.py
|
2015-12-15 17:49:07 +03:00
|
|
|
:language: python
|
|
|
|
|
2016-06-06 11:26:53 +03:00
|
|
|
Limitation for providers type could be used with :py:class:`DynamicContainer`
|
|
|
|
as well:
|
2015-12-15 17:49:07 +03:00
|
|
|
|
2016-06-06 11:26:53 +03:00
|
|
|
.. literalinclude:: ../../examples/containers/dynamic_provider_type.py
|
2015-12-15 17:49:07 +03:00
|
|
|
:language: python
|
2017-02-28 23:08:52 +03:00
|
|
|
|
|
|
|
|
|
|
|
.. disqus::
|