mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-27 12:04:00 +03:00
e0d81c2d28
* Add aiohttp extension module * Add giphynav-aiohttp app * Add missing docstrings * Remove print() call * Remove not needed import from flask extension tests * Improve coroutine provider tests * Add aiohttp extension tests * Update tox.ini * Add aiohttp extras * Try fix Python 3.4 tests * Try fix 3.6 tests * Stop running coroutine tests for Python 3.4 * Rename tests * Remove type hints * Fix pypy and change python version for coverage job to 3.8 * Fix coveralls job * Try fix Python 3.4, 3.5 tests * Make coverage job to run 3.5+ tests * Add tests * Add readme * Update the readmes * Add API docs * Add API docs page * Update changelog
34 lines
852 B
Python
34 lines
852 B
Python
"""Application containers module."""
|
|
|
|
from dependency_injector import containers, providers
|
|
from dependency_injector.ext import aiohttp
|
|
|
|
from aiohttp import web
|
|
from . import giphy, services, views
|
|
|
|
|
|
class ApplicationContainer(containers.DeclarativeContainer):
|
|
"""Application container."""
|
|
|
|
app = aiohttp.Application(web.Application)
|
|
|
|
config = providers.Configuration()
|
|
|
|
giphy_client = providers.Factory(
|
|
giphy.GiphyClient,
|
|
api_key=config.giphy.api_key,
|
|
timeout=config.giphy.request_timeout,
|
|
)
|
|
|
|
search_service = providers.Factory(
|
|
services.SearchService,
|
|
giphy_client=giphy_client,
|
|
)
|
|
|
|
index_view = aiohttp.View(
|
|
views.index,
|
|
search_service=search_service,
|
|
default_query=config.search.default_query,
|
|
default_limit=config.search.default_limit,
|
|
)
|