2015-10-17 00:42:22 +03:00
|
|
|
Creating catalog provider bundles
|
|
|
|
---------------------------------
|
|
|
|
|
|
|
|
``di.AbstractCatalog.Bundle`` is a limited collection of catalog providers.
|
|
|
|
While catalog could be used as a centralized place for particular providers
|
|
|
|
group, such bundles of catalog providers can be used for creating several
|
|
|
|
limited scopes that could be passed to different subsystems.
|
|
|
|
|
|
|
|
``di.AbstractCatalog.Bundle`` has exactly the same API as
|
|
|
|
``di.AbstractCatalog`` except of the limitations on getting providers.
|
|
|
|
|
|
|
|
Each ``di.AbstractCatalog`` has a reference to its bundle class -
|
|
|
|
``di.AbstractCatalog.Bundle``. For example, if some concrete catalog has name
|
|
|
|
``SomeCatalog``, then its bundle class could be reached as
|
|
|
|
``SomeCatalog.Bundle``.
|
|
|
|
|
|
|
|
``di.AbstractCatalog.Bundle`` expects to get the list of its catalog providers
|
|
|
|
as positional arguments and will limit the scope of created bundle to this
|
|
|
|
list.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
.. image:: /images/catalogs/bundles.png
|
|
|
|
:width: 100%
|
|
|
|
:align: center
|
|
|
|
|
2015-10-19 11:39:34 +03:00
|
|
|
Listing of `services.py`:
|
|
|
|
|
|
|
|
.. literalinclude:: ../../examples/catalogs/bundles/services.py
|
|
|
|
:language: python
|
|
|
|
|
|
|
|
Listing of `views.py`:
|
|
|
|
|
|
|
|
.. literalinclude:: ../../examples/catalogs/bundles/views.py
|
|
|
|
:language: python
|
|
|
|
|
|
|
|
Listing of `catalogs.py`:
|
|
|
|
|
|
|
|
.. literalinclude:: ../../examples/catalogs/bundles/catalogs.py
|
2015-10-17 00:42:22 +03:00
|
|
|
:language: python
|