diff --git a/README.rst b/README.rst index b1770d23..0f1c2435 100644 --- a/README.rst +++ b/README.rst @@ -61,7 +61,7 @@ system that consists from several business and platform services: .. code-block:: python - """Example of several Dependency Injector catalogs.""" + """Example of several Dependency Injector IoC containers.""" import sqlite3 import boto.s3.connection @@ -95,12 +95,12 @@ system that consists from several business and platform services: db=Platform.database, token_ttl=3600) -Next example demonstrates usage of these IoC containers with the help of -``@inject`` decorator: +Next example demonstrates usage of ``@inject`` decorator with IoC containers +defined above: .. code-block:: python - """Dependency Injector example.""" + """Dependency Injector @inject decorator example.""" from dependency_injector.injections import inject @@ -110,17 +110,23 @@ Next example demonstrates usage of these IoC containers with the help of @inject(users_service=Services.users) @inject(auth_service=Services.auth) @inject(photos_service=Services.photos) - def main(login, password, photo, users_service, auth_service, photos_service): + def main(users_service, auth_service, photos_service): """Main function.""" - user = users_service.get_user(login) - auth_service.authenticate(user, password) - photos_service.upload_photo(user['id'], photo) + user = users_service.get_user('user') + auth_service.authenticate(user, 'secret') + photos_service.upload_photo(user['id'], 'photo.jpg') if __name__ == '__main__': - main(login='user', password='secret', photo='photo.jpg') + main() + +Alternative definition styles +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Also some alternative definition styles could be used. Like this one: +*Dependecy Injector* supports few other styles of dependency injections +definition. + +Ioc containers could look like this one: .. code-block:: python diff --git a/examples/miniapps/services/README.rst b/examples/miniapps/services/README.rst index 00c11981..833bd44e 100644 --- a/examples/miniapps/services/README.rst +++ b/examples/miniapps/services/README.rst @@ -1,14 +1,8 @@ -Dependency Injector example -=========================== +Dependency Injector IoC containers example +========================================== -Instructions for running: +Instructions for running .. code-block:: bash python main.py - - -.. note:: - - ``catalogs_alt_style_1.py`` and ``catalogs_alt_style_2.py`` contain - examples of atlernative catalogs definition styles. diff --git a/examples/miniapps/services/catalogs.py b/examples/miniapps/services/catalogs.py index 3ff6ca2c..37a5bdf7 100644 --- a/examples/miniapps/services/catalogs.py +++ b/examples/miniapps/services/catalogs.py @@ -1,4 +1,4 @@ -"""Example of several Dependency Injector catalogs.""" +"""Example of several Dependency Injector IoC containers.""" import sqlite3 import boto.s3.connection diff --git a/examples/miniapps/services/catalogs_alt_syntax_1.py b/examples/miniapps/services/catalogs_alt_syntax_1.py index 40863bfa..8cc97603 100644 --- a/examples/miniapps/services/catalogs_alt_syntax_1.py +++ b/examples/miniapps/services/catalogs_alt_syntax_1.py @@ -1,6 +1,6 @@ -"""Example of several Dependency Injector catalogs. +"""Example of several Dependency Injector IoC containers. -Alternative definition style #1. +Alternative injections definition style #1. """ import sqlite3 diff --git a/examples/miniapps/services/catalogs_alt_syntax_2.py b/examples/miniapps/services/catalogs_alt_syntax_2.py index 588b726e..1d5746b9 100644 --- a/examples/miniapps/services/catalogs_alt_syntax_2.py +++ b/examples/miniapps/services/catalogs_alt_syntax_2.py @@ -1,6 +1,6 @@ -"""Example of several Dependency Injector catalogs. +"""Example of several Dependency Injector IoC containers. -Alternative definition style #2. +Alternative injections definition style #2. """ import sqlite3 diff --git a/examples/miniapps/services/main.py b/examples/miniapps/services/main.py index b0da2297..9398c8b3 100644 --- a/examples/miniapps/services/main.py +++ b/examples/miniapps/services/main.py @@ -1,4 +1,4 @@ -"""Dependency Injector example.""" +"""Dependency Injector @inject decorator example.""" from dependency_injector.injections import inject @@ -8,12 +8,12 @@ from catalogs import Services @inject(users_service=Services.users) @inject(auth_service=Services.auth) @inject(photos_service=Services.photos) -def main(login, password, photo, users_service, auth_service, photos_service): +def main(users_service, auth_service, photos_service): """Main function.""" - user = users_service.get_user(login) - auth_service.authenticate(user, password) - photos_service.upload_photo(user['id'], photo) + user = users_service.get_user('user') + auth_service.authenticate(user, 'secret') + photos_service.upload_photo(user['id'], 'photo.jpg') if __name__ == '__main__': - main(login='user', password='secret', photo='photo.jpg') + main()