# HG changeset patch # User Dirk Olmes # Date 1281489981 -7200 # Node ID 5585f3d235416c03ed0ba3808e8df851d27eef32 # Parent e8c2730eb444ccfebb7bf225001114af3b7c5b9e Simplify: no classes needed for simple if diff -r e8c2730eb444 -r 5585f3d23541 FeedList.py --- a/FeedList.py Wed Aug 11 03:23:02 2010 +0200 +++ b/FeedList.py Wed Aug 11 03:26:21 2010 +0200 @@ -7,32 +7,17 @@ def getFeeds(session): preferences = Preferences(session) if preferences.showOnlyUnreadFeeds(): - return UnreadFeeds(session).getFeeds() + return _getUnreadFeeds(session) else: - return AllFeeds(session).getFeeds() - -class AllFeeds(object): - '''A simple feed list that returns all feeds stored in the database''' + return Feed.all(session) - def __init__(self, session): - self.session = session - - def getFeeds(self): - return Feed.all(self.session) - -class UnreadFeeds(object): - '''A feed list that returns only Feed objects that have unread entries''' - - def __init__(self, session): - self.session = session - - def getFeeds(self): - query = self.session.query(FeedEntry).filter(FeedEntry.read == 0) - queryWithOptions = query.options(joinedload("feed")) - result = queryWithOptions.all() - return self._collectFeeds(result) - - def _collectFeeds(self, feedEntries): - feeds = [entry.feed for entry in feedEntries] - uniqueFeeds = set(feeds) - return list(uniqueFeeds) +def _getUnreadFeeds(session): + query = session.query(FeedEntry).filter(FeedEntry.read == 0) + queryWithOptions = query.options(joinedload("feed")) + result = queryWithOptions.all() + return _collectFeeds(result) + +def _collectFeeds(feedEntries): + feeds = [entry.feed for entry in feedEntries] + uniqueFeeds = set(feeds) + return list(uniqueFeeds)