mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-05-22 13:36:15 +03:00
Update aiohttp example and tutorial
This commit is contained in:
parent
315f0c0a62
commit
38514c29c5
|
@ -526,17 +526,18 @@ the ``index`` handler. We will use :ref:`wiring` feature.
|
|||
Edit ``handlers.py``:
|
||||
|
||||
.. code-block:: python
|
||||
:emphasize-lines: 4-7,10-13,17
|
||||
:emphasize-lines: 4-7,10-14,18
|
||||
|
||||
"""Handlers module."""
|
||||
|
||||
from aiohttp import web
|
||||
from dependency_injector.wiring import Provide
|
||||
from dependency_injector.wiring import inject, Provide
|
||||
|
||||
from .services import SearchService
|
||||
from .containers import Container
|
||||
|
||||
|
||||
@inject
|
||||
async def index(
|
||||
request: web.Request,
|
||||
search_service: SearchService = Provide[Container.search_service],
|
||||
|
@ -645,17 +646,18 @@ Let's make some refactoring. We will move these values to the config.
|
|||
Edit ``handlers.py``:
|
||||
|
||||
.. code-block:: python
|
||||
:emphasize-lines: 13-14,16-17
|
||||
:emphasize-lines: 14-15,17-18
|
||||
|
||||
"""Handlers module."""
|
||||
|
||||
from aiohttp import web
|
||||
from dependency_injector.wiring import Provide
|
||||
from dependency_injector.wiring import inject, Provide
|
||||
|
||||
from .services import SearchService
|
||||
from .containers import Container
|
||||
|
||||
|
||||
@inject
|
||||
async def index(
|
||||
request: web.Request,
|
||||
search_service: SearchService = Provide[Container.search_service],
|
||||
|
@ -821,11 +823,11 @@ You should see:
|
|||
giphynavigator/application.py 12 0 100%
|
||||
giphynavigator/containers.py 6 0 100%
|
||||
giphynavigator/giphy.py 14 9 36%
|
||||
giphynavigator/handlers.py 9 0 100%
|
||||
giphynavigator/handlers.py 10 0 100%
|
||||
giphynavigator/services.py 9 1 89%
|
||||
giphynavigator/tests.py 37 0 100%
|
||||
---------------------------------------------------
|
||||
TOTAL 87 10 89%
|
||||
TOTAL 88 10 89%
|
||||
|
||||
.. note::
|
||||
|
||||
|
|
|
@ -111,8 +111,8 @@ The output should be something like:
|
|||
giphynavigator/application.py 12 0 100%
|
||||
giphynavigator/containers.py 6 0 100%
|
||||
giphynavigator/giphy.py 14 9 36%
|
||||
giphynavigator/handlers.py 9 0 100%
|
||||
giphynavigator/handlers.py 10 0 100%
|
||||
giphynavigator/services.py 9 1 89%
|
||||
giphynavigator/tests.py 37 0 100%
|
||||
---------------------------------------------------
|
||||
TOTAL 87 10 89%
|
||||
TOTAL 88 10 89%
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
"""Handlers module."""
|
||||
|
||||
from aiohttp import web
|
||||
from dependency_injector.wiring import Provide
|
||||
from dependency_injector.wiring import inject, Provide
|
||||
|
||||
from .services import SearchService
|
||||
from .containers import Container
|
||||
|
||||
|
||||
@inject
|
||||
async def index(
|
||||
request: web.Request,
|
||||
search_service: SearchService = Provide[Container.search_service],
|
||||
|
|
Loading…
Reference in New Issue
Block a user