mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-05-23 05:56:19 +03:00
Refactor Flask tutorial: Search service
This commit is contained in:
parent
f1c0f9ce3f
commit
5856c49614
|
@ -591,7 +591,7 @@ Github API client setup is done.
|
|||
Search service
|
||||
--------------
|
||||
|
||||
Now it's time to add the ``SearchService``. It will:
|
||||
Now it's time to add ``SearchService``. It will:
|
||||
|
||||
- Perform the search.
|
||||
- Fetch commit extra data for each result.
|
||||
|
@ -672,25 +672,17 @@ Now let's add ``SearchService`` to the container.
|
|||
Edit ``containers.py``:
|
||||
|
||||
.. code-block:: python
|
||||
:emphasize-lines: 9,27-30
|
||||
:emphasize-lines: 6,19-22
|
||||
|
||||
"""Application containers module."""
|
||||
"""Containers module."""
|
||||
|
||||
from dependency_injector import containers, providers
|
||||
from dependency_injector.ext import flask
|
||||
from flask import Flask
|
||||
from flask_bootstrap import Bootstrap
|
||||
from github import Github
|
||||
|
||||
from . import services, views
|
||||
from . import services
|
||||
|
||||
|
||||
class ApplicationContainer(containers.DeclarativeContainer):
|
||||
"""Application container."""
|
||||
|
||||
app = flask.Application(Flask, __name__)
|
||||
|
||||
bootstrap = flask.Extension(Bootstrap)
|
||||
class Container(containers.DeclarativeContainer):
|
||||
|
||||
config = providers.Configuration()
|
||||
|
||||
|
@ -705,8 +697,6 @@ Edit ``containers.py``:
|
|||
github_client=github_client,
|
||||
)
|
||||
|
||||
index_view = flask.View(views.index)
|
||||
|
||||
Make the search work
|
||||
--------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user