diff --git a/examples/miniapps/movie_lister/README.rst b/examples/miniapps/movie_lister/README.rst index 39357662..e81aa815 100644 --- a/examples/miniapps/movie_lister/README.rst +++ b/examples/miniapps/movie_lister/README.rst @@ -1,7 +1,7 @@ A naive example of dependency injection in Python ================================================= -Example implementation of dependency injection in Python from Martin Fowler's +Example implementation of dependency injection on Python from Martin Fowler's article about dependency injection and inversion of control: http://www.martinfowler.com/articles/injection.html @@ -11,7 +11,8 @@ Instructions for running: .. code-block:: bash - python _create_db.py + python create_db.py python app_csv.py python app_db.py + python app_db_csv.py diff --git a/examples/miniapps/movie_lister/_create_db.py b/examples/miniapps/movie_lister/create_db.py similarity index 100% rename from examples/miniapps/movie_lister/_create_db.py rename to examples/miniapps/movie_lister/create_db.py diff --git a/examples/miniapps/movie_lister/movies/listers.py b/examples/miniapps/movie_lister/movies/listers.py index 23448d79..2ae78860 100644 --- a/examples/miniapps/movie_lister/movies/listers.py +++ b/examples/miniapps/movie_lister/movies/listers.py @@ -17,7 +17,7 @@ class MovieLister(object): :param movie_finder: Movie finder instance :type movie_finder: movies.finders.MovieFinder """ - self.movie_finder = movie_finder + self._movie_finder = movie_finder def movies_directed_by(self, director): """Return list of movies that were directed by certain person. @@ -28,7 +28,7 @@ class MovieLister(object): :rtype: list[movies.models.Movie] :return: List of movie instances. """ - return [movie for movie in self.movie_finder.find_all() + return [movie for movie in self._movie_finder.find_all() if movie.director == director] def movies_released_in(self, year): @@ -40,5 +40,5 @@ class MovieLister(object): :rtype: list[movies.models.Movie] :return: List of movie instances. """ - return [movie for movie in self.movie_finder.find_all() + return [movie for movie in self._movie_finder.find_all() if movie.year == year]