From ded43039bf15e8d46c49caf5f762686be019d9e1 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Tue, 23 Sep 2014 18:38:38 +0200 Subject: [PATCH] history: Keep history in private attribute So it is not accessible directly from other actors. --- mopidy/core/history.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mopidy/core/history.py b/mopidy/core/history.py index 787d55d7..23f5d74f 100644 --- a/mopidy/core/history.py +++ b/mopidy/core/history.py @@ -11,7 +11,9 @@ logger = logging.getLogger(__name__) class HistoryController(object): - track_list = [] + + def __init__(self): + self._history = [] def add(self, track): """ @@ -34,7 +36,7 @@ class HistoryController(object): ref_name = ' - '.join(name_parts) track_ref = models.Ref.track(uri=track.uri, name=ref_name) - self.track_list.insert(0, (timestamp, track_ref)) + self._history.insert(0, (timestamp, track_ref)) @property def size(self): @@ -43,7 +45,7 @@ class HistoryController(object): :returns: The number of tracks in the history. :rtype :int """ - return len(self.track_list) + return len(self._history) def get_history(self): """ @@ -51,4 +53,4 @@ class HistoryController(object): :returns: The history as a list of `mopidy.models.Track` :rtype: L{`mopidy.models.Track`} """ - return copy.copy(self.track_list) + return copy.copy(self._history)