# HG changeset patch # User Dirk Olmes # Date 1314248505 -7200 # Node ID 8ec20377bcb0d23749874c46a02f571a3d64fd46 # Parent 71c5dc02ff879753efc75d4b06076d22b3764a5c move getting the entries for a feed to the backend so that the couchdb backend can use a custom view for feed entries diff -r 71c5dc02ff87 -r 8ec20377bcb0 MainWindow.py --- a/MainWindow.py Thu Aug 25 05:39:03 2011 +0200 +++ b/MainWindow.py Thu Aug 25 07:01:45 2011 +0200 @@ -50,7 +50,7 @@ def setupFeedEntries(self): hideReadEntries = self.preferences.hideReadFeedEntries() - self.feedEntries = self.selectedFeed.entriesSortedByUpdateDate(hideReadEntries) + self.feedEntries = self.backend.entriesForFeed(self.selectedFeed, hideReadEntries) self.initFeedDisplayModel() def initFeedDisplayModel(self): diff -r 71c5dc02ff87 -r 8ec20377bcb0 backend/couchdb/CouchDbBackend.py --- a/backend/couchdb/CouchDbBackend.py Thu Aug 25 05:39:03 2011 +0200 +++ b/backend/couchdb/CouchDbBackend.py Thu Aug 25 07:01:45 2011 +0200 @@ -2,6 +2,7 @@ from FeedUpdater import FeedUpdater from Preferences import Preferences from backend.couchdb.Feed import Feed +from backend.couchdb.FeedEntry import FeedEntry import couchdb @@ -20,6 +21,12 @@ return Preferences(self.database) def getFeeds(self): + if self.preferences().showOnlyUnreadFeeds(): + return self._getUnreadFeeds() + else: + return Feed.all(self.database) + + def _getUnreadFeeds(self): raise Exception("not yet implemented") def toggleRead(self, feedEntry): @@ -37,6 +44,13 @@ def deleteFeed(self, feed): raise Exception("not yet implemented") + def entriesForFeed(self, feed, hideReadEntries): + viewName = "feedtest/feedEntries_by_feed" + if hideReadEntries: + viewName = "feedtest/unread_feedEntries_by_feed" + viewResults = self.database.view(viewName) + return [FeedEntry(row) for row in viewResults] + def markFeedEntriesAsRead(self, entries): raise Exception("not yet implemented") diff -r 71c5dc02ff87 -r 8ec20377bcb0 backend/couchdb/Preferences.py --- a/backend/couchdb/Preferences.py Thu Aug 25 05:39:03 2011 +0200 +++ b/backend/couchdb/Preferences.py Thu Aug 25 07:01:45 2011 +0200 @@ -20,3 +20,12 @@ def proxyPort(self): return self._valueForKey("proxyPort") + + def showOnlyUnreadFeeds(self): + return self._valueForKey("showOnlyUnreadFeeds") + + def startMaximized(self): + return self._valueForKey("startMaximized") + + def hideReadFeedEntries(self): + return self._valueForKey("hideReadFeedEntries") \ No newline at end of file diff -r 71c5dc02ff87 -r 8ec20377bcb0 backend/sqlalchemy/SqlAlchemyBackend.py --- a/backend/sqlalchemy/SqlAlchemyBackend.py Thu Aug 25 05:39:03 2011 +0200 +++ b/backend/sqlalchemy/SqlAlchemyBackend.py Thu Aug 25 07:01:45 2011 +0200 @@ -75,6 +75,9 @@ self.session.delete(feed) self.session.commit() + def entriesForFeed(self, feed, hideReadEntries): + return feed.entriesSortedByUpdateDate(hideReadEntries) + def markFeedEntriesAsRead(self, entries): for entry in entries: entry.markRead()