python-dependency-injector/docs/containers/specialization.rst

26 lines
774 B
ReStructuredText
Raw Normal View History

Specialization of containers
----------------------------
2015-12-15 17:49:07 +03:00
.. currentmodule:: dependency_injector.containers
2015-12-15 17:49:07 +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
One of such `builtin` features is a limitation for providers type.
2015-12-15 17:49:07 +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:
.. literalinclude:: ../../examples/containers/declarative_provider_type.py
2015-12-15 17:49:07 +03:00
:language: python
Limitation for providers type could be used with :py:class:`DynamicContainer`
as well:
2015-12-15 17:49:07 +03:00
.. literalinclude:: ../../examples/containers/dynamic_provider_type.py
2015-12-15 17:49:07 +03:00
:language: python
.. disqus::