1.14.7 release
This commit is contained in:
parent
9da9ef7153
commit
b38ade5b69
47
README.rst
47
README.rst
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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``,
|
||||
|
|
Loading…
Reference in New Issue