Update README with more extensive examples

This commit is contained in:
Roman Mogilatov 2016-05-22 16:19:43 +03:00
parent d8d6ba44e4
commit 635c953801

View File

@ -126,7 +126,7 @@ Alternative definition styles
*Dependecy Injector* supports few other styles of dependency injections *Dependecy Injector* supports few other styles of dependency injections
definition. definition.
Ioc containers could look like this one: IoC containers from previous example could look like these:
.. code-block:: python .. code-block:: python
@ -140,7 +140,22 @@ Ioc containers could look like this one:
.kwargs(aws_access_key_id='KEY', .kwargs(aws_access_key_id='KEY',
aws_secret_access_key='SECRET') aws_secret_access_key='SECRET')
or like this one:
class Services(catalogs.DeclarativeCatalog):
"""Catalog of business service providers."""
users = providers.Factory(example.services.Users) \
.kwargs(db=Platform.database)
photos = providers.Factory(example.services.Photos) \
.kwargs(db=Platform.database,
s3=Platform.s3)
auth = providers.Factory(example.services.Auth) \
.kwargs(db=Platform.database,
token_ttl=3600)
or like this these:
.. code-block:: python .. code-block:: python
@ -154,6 +169,21 @@ or like this one:
s3.kwargs(aws_access_key_id='KEY', s3.kwargs(aws_access_key_id='KEY',
aws_secret_access_key='SECRET') aws_secret_access_key='SECRET')
class Services(catalogs.DeclarativeCatalog):
"""Catalog of business service providers."""
users = providers.Factory(example.services.Users)
users.kwargs(db=Platform.database)
photos = providers.Factory(example.services.Photos)
photos.kwargs(db=Platform.database,
s3=Platform.s3)
auth = providers.Factory(example.services.Auth)
auth.kwargs(db=Platform.database,
token_ttl=3600)
You can get more *Dependency Injector* examples in ``/examples`` directory on You can get more *Dependency Injector* examples in ``/examples`` directory on
GitHub: GitHub: