diff --git a/examples/containers/declarative.py b/examples/containers/declarative.py index 2e5fb421..f095d5e9 100644 --- a/examples/containers/declarative.py +++ b/examples/containers/declarative.py @@ -12,6 +12,7 @@ class Container(containers.DeclarativeContainer): factory2 = providers.Factory(object) + # Creating some objects: object1 = Container.factory1() object2 = Container.factory2() diff --git a/examples/miniapps/movie_lister/app_db_csv.py b/examples/miniapps/movie_lister/app_db_csv.py index b224ba40..2f2864d8 100644 --- a/examples/miniapps/movie_lister/app_db_csv.py +++ b/examples/miniapps/movie_lister/app_db_csv.py @@ -71,6 +71,7 @@ class CsvApplication(containers.DeclarativeContainer): csv_file_path=settings.MOVIES_CSV_PATH, delimiter=',') + if __name__ == '__main__': DbApplication.init_db() DbApplication.main() diff --git a/examples/providers/overriding_simple.py b/examples/providers/overriding_simple.py index d68dd5f0..77a5a6d0 100644 --- a/examples/providers/overriding_simple.py +++ b/examples/providers/overriding_simple.py @@ -6,6 +6,7 @@ import dependency_injector.providers as providers class User(object): """Example class User.""" + # Users factory: users_factory = providers.Factory(User) @@ -22,6 +23,7 @@ assert isinstance(user1, User) and isinstance(user2, User) class SuperUser(User): """Example class SuperUser.""" + # Overriding users factory: users_factory.override(providers.Factory(SuperUser)) diff --git a/examples/providers/overriding_users_model.py b/examples/providers/overriding_users_model.py index 84394118..b3ab2adc 100644 --- a/examples/providers/overriding_users_model.py +++ b/examples/providers/overriding_users_model.py @@ -25,6 +25,7 @@ class UsersService(object): """Find user by his id and return user model.""" return self.user_cls(id=id, password='secret' + str(id)) + # Users factory and UsersService provider: users_service = providers.Factory(UsersService, user_cls=User) @@ -69,6 +70,7 @@ class ExtendedUsersService(UsersService): user.gender = 'male' return user + # Overriding users_service provider: extended_users_service = providers.Factory(ExtendedUsersService, user_cls=ExtendedUser)