From 635c95380135bebb1d6e3246c093e4e3626773d0 Mon Sep 17 00:00:00 2001 From: Roman Mogilatov Date: Sun, 22 May 2016 16:19:43 +0300 Subject: [PATCH] Update README with more extensive examples --- README.rst | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 0f1c2435..bb9f09c4 100644 --- a/README.rst +++ b/README.rst @@ -126,7 +126,7 @@ Alternative definition styles *Dependecy Injector* supports few other styles of dependency injections definition. -Ioc containers could look like this one: +IoC containers from previous example could look like these: .. code-block:: python @@ -140,7 +140,22 @@ Ioc containers could look like this one: .kwargs(aws_access_key_id='KEY', 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 @@ -154,6 +169,21 @@ or like this one: s3.kwargs(aws_access_key_id='KEY', 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 GitHub: