mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-27 20:13:59 +03:00
c50322db02
* Add DependenciesContainer provider * Remove bundles_v2 example * Add use cases example * Update changelog * Update documentation requirements to use fixed version of sphinxcontrib-disqus * Add use cases miniapp to docs * Update changelog
31 lines
818 B
Python
31 lines
818 B
Python
"""Dependency injection containers for 'Use Cases' example application."""
|
|
|
|
from dependency_injector import containers, providers
|
|
|
|
from example.adapters import SmtpEmailSender, EchoEmailSender
|
|
from example.use_cases import SignupUseCase
|
|
|
|
|
|
class Adapters(containers.DeclarativeContainer):
|
|
"""Adapters container."""
|
|
|
|
email_sender = providers.Singleton(SmtpEmailSender)
|
|
|
|
|
|
class TestAdapters(containers.DeclarativeContainer):
|
|
"""Adapters container.
|
|
|
|
This container is used for testing purposes.
|
|
"""
|
|
|
|
email_sender = providers.Singleton(EchoEmailSender)
|
|
|
|
|
|
class UseCases(containers.DeclarativeContainer):
|
|
"""Use cases container."""
|
|
|
|
adapters = providers.DependenciesContainer()
|
|
|
|
signup = providers.Factory(SignupUseCase,
|
|
email_sender=adapters.email_sender)
|