python-dependency-injector/docs/catalogs/overriding.rst

23 lines
726 B
ReStructuredText
Raw Normal View History

2015-10-11 15:34:21 +03:00
Overriding of catalogs
----------------------
Catalogs can be overridden by other catalogs. This, actually, means that
all of the providers from overriding catalog will override providers with the
same names in overridden catalog.
There are two ways to override catalog by another catalog:
- Use ``di.AbstractCatalog.override(AnotherCatalog)`` method.
- Use ``@di.override(AnotherCatalog)`` class decorator.
Example of overriding catalog using ``di.AbstractCatalog.override()`` method:
.. literalinclude:: ../../examples/catalogs/override.py
:language: python
Example of overriding catalog using ``@di.override()`` decorator:
.. literalinclude:: ../../examples/catalogs/override_decorator.py
:language: python