Merge branch 'release/3.6.1' into master

This commit is contained in:
Roman Mogylatov 2017-08-08 19:36:51 +03:00
commit a4bb5514b1
8 changed files with 23324 additions and 294 deletions

View File

@ -7,6 +7,10 @@ that were made in every particular version.
From version 0.7.6 *Dependency Injector* framework strictly
follows `Semantic versioning`_
3.6.1
-----
- Regenerate C sources using Cython 0.26.
3.6.0
-----
- Add ``CallableDelegate`` provider.

View File

@ -0,0 +1,41 @@
"""Mail service and user registration DI container example."""
from dependency_injector.containers import DeclarativeContainer
from dependency_injector.providers import Callable, Singleton
import example
class Container(DeclarativeContainer):
"""DI container."""
mail_service = Singleton(example.MailService,
host='localhost',
port=587,
login='my_login',
password='super_secret_password')
add_user = Callable(example.add_user,
mailer=mail_service)
if __name__ == '__main__':
print('Using real mail service:')
Container.add_user('sample@mail.com', 'password')
# Using real mail service:
# Connecting server localhost:587 with my_login:super_secret_password
# Sending "Your password is password" to "sample@mail.com"
print('Using mail service stub:')
Container.add_user('sample@mail.com', 'password',
mailer=example.MailServiceStub())
# Using mail service stub:
# Emulating sending "Your password is password" to "sample@mail.com"
# Also you can override provider by another provider:
Container.mail_service.override(Singleton(example.MailServiceStub))
print('Using mail service stub by overriding mail service provider:')
Container.add_user('sample@mail.com', 'password')
# Using mail service stub by overriding mail service provider:
# Emulating sending "Your password is password" to "sample@mail.com"
Container.mail_service.reset_override() # Resetting provider overriding

View File

@ -0,0 +1,39 @@
"""Mail service and user registration example."""
class AbstractMailService(object):
"""Abstract mail service."""
def send(self, email, body):
"""Send email."""
raise NotImplementedError()
class MailService(AbstractMailService):
"""Mail service."""
def __init__(self, host, port, login, password):
"""Initializer."""
self._host = host
self._port = port
self._login = login
self._password = password
def send(self, email, body):
"""Send email."""
print('Connecting server {0}:{1} with {2}:{3}'.format(
self._host, self._port, self._login, self._password))
print('Sending "{0}" to "{1}"'.format(body, email))
class MailServiceStub(AbstractMailService):
"""Mail service stub."""
def send(self, email, body):
"""Send email."""
print('Emulating sending "{0}" to "{1}"'.format(body, email))
def add_user(email, password, mailer):
"""Register user."""
mailer.send(email, 'Your password is {0}'.format(password))

View File

@ -1,4 +1,4 @@
cython
cython==0.26
tox
unittest2
coverage

View File

@ -7,7 +7,8 @@ from setuptools import setup, Extension
# Defining setup variables:
defined_macros = list()
defined_macros = dict()
defined_macros['CYTHON_CLINE_IN_TRACEBACK'] = 0
# Getting description:
with open('README.rst') as readme_file:
@ -23,8 +24,9 @@ with open('src/dependency_injector/__init__.py') as init_file:
# Adding debug options:
if os.environ.get('DEPENDENCY_INJECTOR_DEBUG_MODE') == '1':
defined_macros.append(('CYTHON_TRACE', 1))
defined_macros.append(('CYTHON_TRACE_NOGIL', 1))
defined_macros['CYTHON_TRACE'] = 1
defined_macros['CYTHON_TRACE_NOGIL'] = 1
defined_macros['CYTHON_CLINE_IN_TRACEBACK'] = 1
setup(name='dependency-injector',
@ -47,11 +49,11 @@ setup(name='dependency-injector',
ext_modules=[
Extension('dependency_injector.containers',
['src/dependency_injector/containers.c'],
define_macros=defined_macros,
define_macros=list(defined_macros.items()),
extra_compile_args=['-O2']),
Extension('dependency_injector.providers',
['src/dependency_injector/providers.c'],
define_macros=defined_macros,
define_macros=list(defined_macros.items()),
extra_compile_args=['-O2']),
],
package_data={

View File

@ -1,6 +1,6 @@
"""Dependency injector top-level package."""
__version__ = '3.6.0'
__version__ = '3.6.1'
"""Version number that follows semantic versioning.
:type: str

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff