1.14.7 release

This commit is contained in:
Roman Mogilatov 2016-02-27 00:13:42 +02:00
parent 9da9ef7153
commit b38ade5b69
3 changed files with 51 additions and 2 deletions

View File

@ -64,7 +64,52 @@ Examples
.. code-block:: python
"""Concept example of `Dependency Injector`."""
"""Pythonic way for Dependency Injection."""
from dependency_injector import providers
from dependency_injector import injections
@providers.DelegatedCallable
def get_user_info(user_id):
"""Return user info."""
raise NotImplementedError()
@providers.Factory
@injections.inject(get_user_info=get_user_info)
class AuthComponent(object):
"""Some authentication component."""
def __init__(self, get_user_info):
"""Initializer."""
self.get_user_info = get_user_info
def authenticate_user(self, token):
"""Authenticate user by token."""
user_info = self.get_user_info(user_id=token + '1')
return user_info
print AuthComponent
print get_user_info
@get_user_info.override
@providers.DelegatedCallable
def get_user_info(user_id):
"""Return user info."""
return {'user_id': user_id}
print AuthComponent().authenticate_user(token='abc')
# {'user_id': 'abc1'}
One more example with Catalog:
.. code-block:: python
"""Pythonic way for Dependency Injection (example with Catalog)."""
import sqlite3

View File

@ -51,7 +51,7 @@ from .errors import UndefinedProviderError
from . import catalogs
catalog = catalogs
VERSION = '1.14.6'
VERSION = '1.14.7'
"""Version number that follows semantic versioning.
:type: str

View File

@ -11,6 +11,10 @@ Development version
-------------------
- No features.
1.14.7
------
- Add one more example in README (inline providers and injections).
1.14.6
------
- Add ``cls`` alias for ``provides`` attributes of ``Factory``,