mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-27 08:19:57 +03:00
Update wiring docs
This commit is contained in:
parent
5a6aed9d4f
commit
8036e7056f
|
@ -174,19 +174,28 @@ You can use that in testing to re-create and re-wire a container before each tes
|
||||||
Integration with other frameworks
|
Integration with other frameworks
|
||||||
---------------------------------
|
---------------------------------
|
||||||
|
|
||||||
Wiring feature helps integrate the container providers with other frameworks:
|
Wiring feature helps to integrate with other frameworks like Django, Flask, etc.
|
||||||
Django, Flask, Aiohttp, Sanic, your custom framework, etc.
|
|
||||||
|
|
||||||
With wiring you do not need to change the traditional application structure of your framework.
|
With wiring you do not need to change the traditional application structure of your framework.
|
||||||
|
|
||||||
1. Create a container and put framework-independent components as providers.
|
1. Create a container and put framework-independent components as providers.
|
||||||
2. Place wiring markers in the functions and methods where you want the providers
|
2. Place wiring markers in the functions and methods where you want the providers
|
||||||
to be injected (Flask or Django views, Aiohttp or Sanic handlers, etc).
|
to be injected (Flask or Django views, Aiohttp or Sanic handlers, etc).
|
||||||
3. Wire the container with the application.
|
3. Wire the container with the application modules.
|
||||||
4. Run the application.
|
4. Run the application.
|
||||||
|
|
||||||
.. literalinclude:: ../examples/wiring/flask_example.py
|
.. literalinclude:: ../examples/wiring/flask_example.py
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 3-
|
:lines: 3-
|
||||||
|
|
||||||
|
Take a look at other application examples:
|
||||||
|
|
||||||
|
- :ref:`application-single-container`
|
||||||
|
- :ref:`application-multiple-containers`
|
||||||
|
- :ref:`decoupled-packages`
|
||||||
|
- :ref:`django-example`
|
||||||
|
- :ref:`flask-example`
|
||||||
|
- :ref:`aiohttp-example`
|
||||||
|
- :ref:`sanic-example`
|
||||||
|
|
||||||
.. disqus::
|
.. disqus::
|
||||||
|
|
Loading…
Reference in New Issue
Block a user