class ApplicationContainer(containers.DeclarativeContainer):

    app = flask.Application(Flask, __name__)

    index_view = flask.View(index)
    test_view = flask.View(test)
    test_class_view = flask.ClassBasedView(Test)
Exemple #2
0
class ApplicationContainer(containers.DeclarativeContainer):
    """Application container."""

    app = flask.Application(Flask, __name__)

    bootstrap = flask.Extension(Bootstrap)

    config = providers.Configuration()

    github_client = providers.Factory(
        Github,
        login_or_token=config.github.auth_token,
        timeout=config.github.request_timeout,
    )

    search_service = providers.Factory(
        services.SearchService,
        github_client=github_client,
    )

    index_view = flask.View(
        views.index,
        search_service=search_service,
        default_query=config.search.default_query,
        default_limit=config.search.default_limit,
    )
class Container(containers.DeclarativeContainer):

    app = flask.Application(Flask, __name__)

    # Configuración
    config = providers.Configuration('config')

    # Dependencias
    logger = providers.Singleton(logging.Logger, name='logger')
    psycopg2_data_manager = providers.Singleton(Psycopg2DataManager,
                                                user=config.username,
                                                password=config.password,
                                                host=config.host,
                                                port=config.port,
                                                db_name=config.db_name)

    sqlalchemy_orm_data_manager = providers.Singleton(SqlAlchemyORMDataManager,
                                                      user=config.username,
                                                      password=config.password,
                                                      host=config.host,
                                                      port=config.port,
                                                      db_name=config.db_name)

    # Servicios
    gestor_pedidos = providers.Selector(
        config.data_handler,
        psycopg2=providers.Singleton(GestorPedidos, psycopg2_data_manager,
                                     logger),
        sqlalchemy=providers.Singleton(GestorPedidos,
                                       sqlalchemy_orm_data_manager, logger),
    )
Exemple #4
0
class ProdAppContainer(containers.DeclarativeContainer):
    app = flask.Application(Flask, __name__)

    comments_repository = providers.Factory(DynamoCommentsRepository)

    get_comments_view = flask.View(controllers.get_comments,
                                   comments_repository=comments_repository)
    add_comment_view = flask.View(controllers.add_comment,
                                  comments_repository=comments_repository)
Exemple #5
0
class DevAppContainer(containers.DeclarativeContainer):
    app = flask.Application(Flask, __name__)

    # InMemory repository is used in development to avoid use Dynamo AWS
    comments_repository = providers.Factory(InMemoryCommentsRepository,
                                            json_path='src/data/comments.json')

    get_comments_view = flask.View(controllers.get_comments,
                                   comments_repository=comments_repository)
    add_comment_view = flask.View(controllers.add_comment,
                                  comments_repository=comments_repository)