mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 17:47:02 +03:00
c50322db02
* Add DependenciesContainer provider * Remove bundles_v2 example * Add use cases example * Update changelog * Update documentation requirements to use fixed version of sphinxcontrib-disqus * Add use cases miniapp to docs * Update changelog
58 lines
1.3 KiB
ReStructuredText
58 lines
1.3 KiB
ReStructuredText
Use cases mini application example
|
|
----------------------------------
|
|
|
|
.. currentmodule:: dependency_injector.providers
|
|
|
|
"Use cases" miniapp demonstrate usage of :py:class:`DependenciesContainer`
|
|
provider.
|
|
|
|
Example application
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
"Use cases" mini application has next structure:
|
|
|
|
.. code-block:: bash
|
|
|
|
use_cases/
|
|
example/ <-- Example package
|
|
__init__.py
|
|
adapters.py
|
|
use_cases.py
|
|
containers.py <-- Dependency injection containers
|
|
run.py <-- Entrypoint
|
|
|
|
|
|
IoC containers
|
|
~~~~~~~~~~~~~~
|
|
|
|
Listing of ``use_cases/containers.py``:
|
|
|
|
.. literalinclude:: ../../examples/miniapps/use_cases/containers.py
|
|
:language: python
|
|
:linenos:
|
|
|
|
Run application
|
|
~~~~~~~~~~~~~~~
|
|
|
|
Listing of ``run.py``:
|
|
|
|
.. literalinclude:: ../../examples/miniapps/use_cases/run.py
|
|
:language: python
|
|
:linenos:
|
|
|
|
Instructions for running:
|
|
|
|
.. code-block:: bash
|
|
|
|
python run.py prod example@example.com # Running in "production" environment
|
|
python run.py test example@example.com # Running in "testing" environment
|
|
|
|
Links
|
|
~~~~~
|
|
|
|
+ `Dependency Injector <https://github.com/ets-labs/python-dependency-injector/>`_
|
|
+ `Full example sources <https://github.com/ets-labs/python-dependency-injector/tree/master/examples/miniapps/use_cases>`_
|
|
|
|
|
|
.. disqus::
|