diff --git a/examples/miniapps/application-multiple-containers/README.rst b/examples/miniapps/application-multiple-containers/README.rst index fe9840de..69534c52 100644 --- a/examples/miniapps/application-multiple-containers/README.rst +++ b/examples/miniapps/application-multiple-containers/README.rst @@ -24,6 +24,6 @@ You should see: .. code-block:: bash - [2020-09-04 16:06:00,750] [DEBUG] [example.services.UserService]: User user@example.com has been found in database - [2020-09-04 16:06:00,750] [DEBUG] [example.services.AuthService]: User user@example.com has been successfully authenticated - [2020-09-04 16:06:00,750] [DEBUG] [example.services.PhotoService]: Photo photo.jpg has been successfully uploaded by user user@example.com + [2020-10-06 15:36:55,961] [DEBUG] [example.services.UserService]: User user@example.com has been found in database + [2020-10-06 15:36:55,961] [DEBUG] [example.services.AuthService]: User user@example.com has been successfully authenticated + [2020-10-06 15:36:55,961] [DEBUG] [example.services.PhotoService]: Photo photo.jpg has been successfully uploaded by user user@example.com diff --git a/examples/miniapps/application-multiple-containers/example/__main__.py b/examples/miniapps/application-multiple-containers/example/__main__.py index 1d8eefc4..e6e8e6ac 100644 --- a/examples/miniapps/application-multiple-containers/example/__main__.py +++ b/examples/miniapps/application-multiple-containers/example/__main__.py @@ -2,23 +2,29 @@ import sys +from dependency_injector.wiring import Provide + +from .services import UserService, AuthService, PhotoService from .containers import Application -def main(email: str, password: str, photo: str) -> None: - application = Application() - - application.config.from_yaml('config.yml') - application.core.configure_logging() - - user_service = application.services.user() - auth_service = application.services.auth() - photo_service = application.services.photo() - +def main( + email: str, + password: str, + photo: str, + user_service: UserService = Provide[Application.services.user], + auth_service: AuthService = Provide[Application.services.auth], + photo_service: PhotoService = Provide[Application.services.photo], +): user = user_service.get_user(email) auth_service.authenticate(user, password) photo_service.upload_photo(user, photo) if __name__ == '__main__': + application = Application() + application.config.from_yaml('config.yml') + application.core.configure_logging() + application.wire(modules=[sys.modules[__name__]]) + main(*sys.argv[1:])