diff backend/sqlalchemy/FeedUpdater.py @ 167:a3c945ce434c

adjust the sqlalchemy backend to the changes in AbstractFeedUpdater
author dirk
date Mon, 05 Sep 2011 19:39:08 +0200
parents 86f828096aaf
children f4708d38419c
line wrap: on
line diff
--- a/backend/sqlalchemy/FeedUpdater.py	Sat Sep 03 04:12:35 2011 +0200
+++ b/backend/sqlalchemy/FeedUpdater.py	Mon Sep 05 19:39:08 2011 +0200
@@ -1,18 +1,17 @@
 
+from Feed import Feed
+from FeedEntry import FeedEntry
 from backend.AbstractFeedUpdater import AbstractFeedUpdater, FeedUpdateException
 from datetime import datetime
-from Feed import Feed
-from FeedEntry import FeedEntry
-import feedparser
 import logging
 
 log = logging.getLogger("FeedUpdater")
 
-def updateAllFeeds(session):
+def updateAllFeeds(preferences, session):
     allFeeds = findFeedsToUpdate(session)
     for feed in allFeeds:
         try:
-            FeedUpdater(session, feed).update()
+            FeedUpdater(preferences, session).update(feed)
         except FeedUpdateException, fue:
             log.warn("problems while updating feed " + feed.rss_url + ": " + str(fue))
         session.commit()
@@ -20,22 +19,10 @@
 def findFeedsToUpdate(session):
     return session.query(Feed).filter(Feed.next_update < datetime.now())
 
-def createNewFeed(url, session):
-    # when updating to python3 see http://code.google.com/p/feedparser/issues/detail?id=260
-    result = feedparser.parse(url)
-    if result.has_key("title"):
-        title = result["feed"].title
-    else:
-        title = url
-    newFeed = Feed(title, url)
-    session.add(newFeed)
-
-    FeedUpdater(session, newFeed).update(result)
-
 
 class FeedUpdater(AbstractFeedUpdater):
-    def __init__(self, session, feed):
-        AbstractFeedUpdater.__init__(self, feed)
+    def __init__(self, preferences, session):
+        AbstractFeedUpdater.__init__(self, preferences)
         self.session = session
 
     def _processEntry(self, entry):