Mercurial > hg > Feedworm
diff backend/sqlalchemy/SqlAlchemyBackend.py @ 153:65c4bb6d5add
move management of the selected feed entry into the backend - sqlachemy backend works, couchdb backend currently broken
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Sat, 27 Aug 2011 07:29:33 +0200 |
parents | bca9341dc67f |
children | 2682db280be0 |
line wrap: on
line diff
--- a/backend/sqlalchemy/SqlAlchemyBackend.py Sat Aug 27 07:11:08 2011 +0200 +++ b/backend/sqlalchemy/SqlAlchemyBackend.py Sat Aug 27 07:29:33 2011 +0200 @@ -23,6 +23,8 @@ self.updater = None self.feeds = [] self.selectedFeed = None + self.feedEntries = None + self.selectedFeedEntry = None def _initLogging(self): logging.getLogger("sqlalchemy.orm").setLevel(logging.WARN) @@ -35,6 +37,10 @@ def preferences(self): return self.prefs + # + # handling of feeds + # + def getFeeds(self): if self.preferences().showOnlyUnreadFeeds(): self.feeds = self._getUnreadFeeds() @@ -55,10 +61,14 @@ def selectFeed(self, index): self.selectedFeed = self.feeds[index] + self.feedEntries = None return self.selectedFeed - def entriesForSelectedFeed(self, hideReadEntries): - return self.selectedFeed.entriesSortedByUpdateDate(hideReadEntries) + def entriesForSelectedFeed(self): + hideReadEntries = self.prefs.hideReadFeedEntries() + if self.feedEntries is None: + self.feedEntries = self.selectedFeed.entriesSortedByUpdateDate(hideReadEntries) + return self.feedEntries def markSelectedFeedAsRead(self): self.selectedFeed.markAllEntriesRead() @@ -68,11 +78,24 @@ self.session.delete(self.selectedFeed) self.session.commit() + # + # handling of the selected feed entry + # + def selectFeedEntry(self, index): + self.selectedFeedEntry = self.feedEntries[index] + self.selectedFeedEntry.markRead() + return self.selectedFeedEntry + + def markFeedEntriesAsRead(self, indices): + for index in indices: + self.feedEntries[index].markRead() + self.session.commit() + + def toggleSelectedFeedEntryRead(self): + self.selectedFeedEntry.toggleRead() + self.session.commit() - def toggleRead(self, feedEntry): - feedEntry.toggleRead() - self.session.commit() def createFeed(self, url): try: @@ -88,10 +111,6 @@ self.session.commit() - def markFeedEntriesAsRead(self, entries): - for entry in entries: - entry.markRead() - self.session.commit() def updateAllFeeds(self): FeedUpdater.updateAllFeeds(self.session)