mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 09:36:48 +03:00
Update movie listers example
This commit is contained in:
parent
860b44f33b
commit
bd5ea87ef7
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue
Block a user