diff backend/couchdb/FeedUpdater.py @ 166:04c3b9796b89

feedparser uses the proxy now if one is configured. To implement this the FeedUpdater had to change a bit - sqlalchemy backend is not yet refactored.
author dirk
date Sat, 03 Sep 2011 04:12:35 +0200
parents 2940e74c9663
children a9ba3e3a9a9a
line wrap: on
line diff
--- a/backend/couchdb/FeedUpdater.py	Mon Aug 29 04:12:01 2011 +0200
+++ b/backend/couchdb/FeedUpdater.py	Sat Sep 03 04:12:35 2011 +0200
@@ -1,26 +1,13 @@
 
-from Feed import Feed
 from FeedEntry import FeedEntry
 from backend.AbstractFeedUpdater import AbstractFeedUpdater
 import logging
-import feedparser
 
 log = logging.getLogger("FeedUpdater")
 
 class FeedUpdater(AbstractFeedUpdater):
-    @staticmethod
-    def createFeed(url, database):
-        feedDict = feedparser.parse(url)
-        if feedDict.has_key("title"):
-            title = feedDict["feed"].title
-        else:
-            title = url
-        feed = Feed.create(url, title)
-        feed.store(database)
-        FeedUpdater(feed, database).update(feedDict)
-
-    def __init__(self, feed, database):
-        AbstractFeedUpdater.__init__(self, feed)
+    def __init__(self, database, preferences):
+        AbstractFeedUpdater.__init__(self, preferences)
         self.database = database
 
     def _processEntry(self, entry):
@@ -41,3 +28,9 @@
     def _incrementFeedUpdateDate(self):
         self.feed.incrementNextUpdateDate()
         self.feed.store(self.database)
+
+    def _setFeedTitle(self, feedDict):
+        oldTitle = self.feed.title
+        AbstractFeedUpdater._setFeedTitle(self, feedDict)
+        if oldTitle != self.feed.title:
+            self.feed.store(self.database)