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