mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-02-10 16:40:49 +03:00
Add single container docs page
This commit is contained in:
parent
04f22e6152
commit
4c5a5192b0
22
docs/examples-other/index.rst
Normal file
22
docs/examples-other/index.rst
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
Other examples
|
||||||
|
==============
|
||||||
|
|
||||||
|
.. meta::
|
||||||
|
:keywords: Python,DI,Dependency injection,IoC,Inversion of Control
|
||||||
|
:description: Current section of documentation is designed to provide
|
||||||
|
several example mini applications that are built on the top
|
||||||
|
of inversion of control principle and powered by
|
||||||
|
"Dependency Injector" framework.
|
||||||
|
|
||||||
|
Current section of documentation is designed to provide several example mini
|
||||||
|
applications that are built according to the inversion of control principle
|
||||||
|
and powered by *Dependency Injector* framework.
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
|
||||||
|
bundles_miniapp
|
||||||
|
use_cases_miniapp
|
||||||
|
password_hashing_miniapp
|
||||||
|
chained_factories
|
||||||
|
factory_of_factories
|
BIN
docs/examples/images/services-miniapp.png
Normal file
BIN
docs/examples/images/services-miniapp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
|
@ -2,23 +2,13 @@ Examples
|
||||||
========
|
========
|
||||||
|
|
||||||
.. meta::
|
.. meta::
|
||||||
:keywords: Python,DI,Dependency injection,IoC,Inversion of Control
|
:keywords: Python,DI,Dependency injection,IoC,Inversion of Control,Example
|
||||||
:description: Current section of documentation is designed to provide
|
:description: Python dependency injection examples.
|
||||||
several example mini applications that are built on the top
|
|
||||||
of inversion of control principle and powered by
|
|
||||||
"Dependency Injector" framework.
|
|
||||||
|
|
||||||
Current section of documentation is designed to provide several example mini
|
Explore the examples to see the ``Dependency Injector`` in action.
|
||||||
applications that are built according to the inversion of control principle
|
|
||||||
and powered by *Dependency Injector* framework.
|
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|
||||||
services_miniapp_v1
|
services-single-container
|
||||||
services_miniapp_v2
|
services-multiple-containers
|
||||||
bundles_miniapp
|
|
||||||
use_cases_miniapp
|
|
||||||
password_hashing_miniapp
|
|
||||||
chained_factories
|
|
||||||
factory_of_factories
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Services mini application example (v2 - single container)
|
Services mini application example (multiple containers)
|
||||||
---------------------------------------------------------
|
=======================================================
|
||||||
|
|
||||||
.. meta::
|
.. meta::
|
||||||
:description: "Services miniapp" is an example mini application that
|
:description: "Services miniapp" is an example mini application that
|
82
docs/examples/services-single-container.rst
Normal file
82
docs/examples/services-single-container.rst
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
Services mini application example (single container)
|
||||||
|
====================================================
|
||||||
|
|
||||||
|
.. meta::
|
||||||
|
:description: "Services miniapp" is an example mini application that
|
||||||
|
consists from several services that have dependencies on
|
||||||
|
some standard and 3rd-party libraries for logging,
|
||||||
|
interaction with database and remote service via API.
|
||||||
|
"Services miniapp" example demonstrates usage of
|
||||||
|
Dependency Injector for creating several inversion of control /
|
||||||
|
dependency injection containers.
|
||||||
|
|
||||||
|
"Services" is an example mini application. It consists from several services that have
|
||||||
|
dependencies on database & AWS S3.
|
||||||
|
|
||||||
|
.. image:: images/services-miniapp.png
|
||||||
|
:width: 100%
|
||||||
|
:align: center
|
||||||
|
|
||||||
|
Start from the scratch or jump to the section:
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
:backlinks: none
|
||||||
|
|
||||||
|
Application structure
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Application consists from ``example`` package, several configuration files and ``requirements.txt``.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
./
|
||||||
|
├── example/
|
||||||
|
│ ├── __init__.py
|
||||||
|
│ ├── __main__.py
|
||||||
|
│ ├── containers.py
|
||||||
|
│ └── services.py
|
||||||
|
├── config.ini
|
||||||
|
├── logging.ini
|
||||||
|
└── requirements.txt
|
||||||
|
|
||||||
|
Container
|
||||||
|
---------
|
||||||
|
|
||||||
|
Listing of ``example/containers.py``:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/miniapps/services-single-container/example/containers.py
|
||||||
|
:language: python
|
||||||
|
|
||||||
|
Listing of ``example/__main__.py``:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/miniapps/services-single-container/example/__main__.py
|
||||||
|
:language: python
|
||||||
|
|
||||||
|
Services
|
||||||
|
--------
|
||||||
|
|
||||||
|
Listing of ``example/services.py``:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/miniapps/services-single-container/example/services.py
|
||||||
|
:language: python
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Listing of ``config.ini``:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/miniapps/services-single-container/config.ini
|
||||||
|
:language: ini
|
||||||
|
|
||||||
|
Listing of ``logging.ini``:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/miniapps/services-single-container/logging.ini
|
||||||
|
:language: ini
|
||||||
|
|
||||||
|
Sources on Github
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
To find the source code navigate to the `Github <https://github.com/ets-labs/python-dependency-injector/tree/master/examples/miniapps/services-single-container>`_.
|
||||||
|
|
||||||
|
.. disqus::
|
|
@ -1,73 +0,0 @@
|
||||||
Services mini application example (v1 - multiple containers)
|
|
||||||
------------------------------------------------------------
|
|
||||||
|
|
||||||
.. meta::
|
|
||||||
:description: "Services miniapp" is an example mini application that
|
|
||||||
consists from several services that have dependencies on
|
|
||||||
some standard and 3rd-party libraries for logging,
|
|
||||||
interaction with database and remote service via API.
|
|
||||||
"Services miniapp" example demonstrates usage of
|
|
||||||
Dependency Injector for creating several inversion of control /
|
|
||||||
dependency injection containers.
|
|
||||||
|
|
||||||
"Services miniapp" is an example mini application that consists from several
|
|
||||||
services that have dependencies on some standard and 3rd-party libraries for
|
|
||||||
logging, interaction with database and remote service calls via API.
|
|
||||||
|
|
||||||
"Services miniapp" example demonstrates usage of
|
|
||||||
:doc:`Dependency Injector <../index>` for creating several IoC containers.
|
|
||||||
|
|
||||||
Instructions for running:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
python run.py 1 secret photo.jpg
|
|
||||||
|
|
||||||
Example application
|
|
||||||
~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Classes diagram:
|
|
||||||
|
|
||||||
.. image:: /images/miniapps/services/classes.png
|
|
||||||
:width: 100%
|
|
||||||
:align: center
|
|
||||||
|
|
||||||
|
|
||||||
Example application structure:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
/example
|
|
||||||
/__init__.py
|
|
||||||
/main.py
|
|
||||||
/services.py
|
|
||||||
|
|
||||||
|
|
||||||
Listing of ``example/services.py``:
|
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/miniapps/services_v1/example/services.py
|
|
||||||
:language: python
|
|
||||||
|
|
||||||
Listing of ``example/main.py``:
|
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/miniapps/services_v1/example/main.py
|
|
||||||
:language: python
|
|
||||||
|
|
||||||
IoC containers
|
|
||||||
~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Listing of ``containers.py``:
|
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/miniapps/services_v1/containers.py
|
|
||||||
:language: python
|
|
||||||
|
|
||||||
Run application
|
|
||||||
~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Listing of ``run.py``:
|
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/miniapps/services_v1/run.py
|
|
||||||
:language: python
|
|
||||||
|
|
||||||
|
|
||||||
.. disqus::
|
|
Binary file not shown.
Before Width: | Height: | Size: 49 KiB |
|
@ -131,9 +131,10 @@ Contents
|
||||||
introduction/index
|
introduction/index
|
||||||
main/installation
|
main/installation
|
||||||
tutorials/index
|
tutorials/index
|
||||||
|
examples/index
|
||||||
providers/index
|
providers/index
|
||||||
containers/index
|
containers/index
|
||||||
examples/index
|
examples-other/index
|
||||||
api/index
|
api/index
|
||||||
main/feedback
|
main/feedback
|
||||||
main/changelog
|
main/changelog
|
||||||
|
|
Loading…
Reference in New Issue
Block a user