diff backend/sqlalchemy/SqlAlchemyBackend.py @ 151:bca9341dc67f

move the selected feed into the backend - sqlalchemy backend works, couchdb backend currently broken
author Dirk Olmes <dirk@xanthippe.ping.de>
date Sat, 27 Aug 2011 07:07:50 +0200
parents 8ec20377bcb0
children 65c4bb6d5add
line wrap: on
line diff
--- a/backend/sqlalchemy/SqlAlchemyBackend.py	Sat Aug 27 06:43:28 2011 +0200
+++ b/backend/sqlalchemy/SqlAlchemyBackend.py	Sat Aug 27 07:07:50 2011 +0200
@@ -21,6 +21,8 @@
         self.session = Database.createSession()
         self.prefs = Preferences(self.session)
         self.updater = None
+        self.feeds = []
+        self.selectedFeed = None
 
     def _initLogging(self):
         logging.getLogger("sqlalchemy.orm").setLevel(logging.WARN)
@@ -35,9 +37,10 @@
 
     def getFeeds(self):
         if self.preferences().showOnlyUnreadFeeds():
-            return self._getUnreadFeeds()
+            self.feeds = self._getUnreadFeeds()
         else:
-            return Feed.all(self.session)
+            self.feeds = Feed.all(self.session)
+        return self.feeds
 
     def _getUnreadFeeds(self):
         query = self.session.query(FeedEntry).filter(FeedEntry.read == 0)
@@ -50,14 +53,27 @@
         uniqueFeeds = set(feeds)
         return list(uniqueFeeds)
 
+    def selectFeed(self, index):
+        self.selectedFeed = self.feeds[index]
+        return self.selectedFeed
+
+    def entriesForSelectedFeed(self, hideReadEntries):
+        return self.selectedFeed.entriesSortedByUpdateDate(hideReadEntries)
+
+    def markSelectedFeedAsRead(self):
+        self.selectedFeed.markAllEntriesRead()
+        self.session.commit()
+
+    def deleteSelectedFeed(self):
+        self.session.delete(self.selectedFeed)
+        self.session.commit()
+
+
+
     def toggleRead(self, feedEntry):
         feedEntry.toggleRead()
         self.session.commit()
 
-    def markAllEntriesRead(self, feed):
-        feed.markAllEntriesRead()
-        self.session.commit()
-
     def createFeed(self, url):
         try:
             FeedUpdater.createNewFeed(url, self.session)
@@ -71,12 +87,6 @@
         feed.incrementNextUpdateDate()
         self.session.commit()
 
-    def deleteFeed(self, feed):
-        self.session.delete(feed)
-        self.session.commit()
-
-    def entriesForFeed(self, feed, hideReadEntries):
-        return feed.entriesSortedByUpdateDate(hideReadEntries)
 
     def markFeedEntriesAsRead(self, entries):
         for entry in entries: