Advice on where to define dependency injection providers
Victor Porton
porton at narod.ru
Thu Feb 1 01:44:13 EST 2018
I define ExecutionContext in xmlboiler.core.execution_context module.
ExecutionContext is meant to contain a common "environment" suitable for
different kinds of tasks.
Currently ExecutionContext contains a logger and a translator of messages:
class ExecutionContext(object):
def __init__(self, logger, translations):
"""
:param logger: logger
:param translations: usually should be gettext.GNUTranslations
"""
self.logger = logger
self.translations = translations
Now I want to define some "provides" using dependency_injector.providers
module.
Where (in which module) should I define default factories for loggers,
translations, and execution contexts? (Default logger should log to stderr,
default translations should respect LANG environment variable.)
The only quite clear thing is that providers should be defined somewhere in
xmlboiler.core.* namespace, because it is the namespace for the core library
(to be used by several applications).
Should I define providers in xmlboiler.core.execution_context module or in
something like xmlboiler.core.execution_context_build, or maybe in something
like xmlboiler.core.providers.execution_context?
--
Victor Porton - http://portonvictor.org
More information about the Python-list
mailing list