Mercurial > hg > Feedworm
diff backend/sqlalchemy/FeedUpdater.py @ 168:f4708d38419c
move methods around so the SqlAlchemyBackend only needs to import the class
author | dirk |
---|---|
date | Mon, 05 Sep 2011 19:43:34 +0200 |
parents | a3c945ce434c |
children | bb3c851b18b1 |
line wrap: on
line diff
--- a/backend/sqlalchemy/FeedUpdater.py Mon Sep 05 19:39:08 2011 +0200 +++ b/backend/sqlalchemy/FeedUpdater.py Mon Sep 05 19:43:34 2011 +0200 @@ -7,20 +7,20 @@ log = logging.getLogger("FeedUpdater") -def updateAllFeeds(preferences, session): - allFeeds = findFeedsToUpdate(session) - for feed in allFeeds: - try: - FeedUpdater(preferences, session).update(feed) - except FeedUpdateException, fue: - log.warn("problems while updating feed " + feed.rss_url + ": " + str(fue)) - session.commit() - -def findFeedsToUpdate(session): +def _findFeedsToUpdate(session): return session.query(Feed).filter(Feed.next_update < datetime.now()) +class FeedUpdater(AbstractFeedUpdater): + @staticmethod + def updateAllFeeds(preferences, session): + allFeeds = _findFeedsToUpdate(session) + for feed in allFeeds: + try: + FeedUpdater(preferences, session).update(feed) + except FeedUpdateException, fue: + log.warn("problems while updating feed " + feed.rss_url + ": " + str(fue)) + session.commit() -class FeedUpdater(AbstractFeedUpdater): def __init__(self, preferences, session): AbstractFeedUpdater.__init__(self, preferences) self.session = session