Mercurial > hg > Feedworm
changeset 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 | 91a24f499318 |
files | backend/sqlalchemy/FeedUpdater.py backend/sqlalchemy/SqlAlchemyBackend.py |
diffstat | 2 files changed, 13 insertions(+), 13 deletions(-) [+] |
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
--- a/backend/sqlalchemy/SqlAlchemyBackend.py Mon Sep 05 19:39:08 2011 +0200 +++ b/backend/sqlalchemy/SqlAlchemyBackend.py Mon Sep 05 19:43:34 2011 +0200 @@ -1,13 +1,13 @@ from Feed import Feed from FeedEntry import FeedEntry +from FeedUpdater import FeedUpdater from Preferences import Preferences from backend.AbstractBackend import AbstractBackend from datetime import datetime, timedelta from sqlalchemy.orm import joinedload from sqlalchemy.sql import and_ import Database -import FeedUpdater import Mapping import logging import util @@ -78,7 +78,7 @@ newFeed = Feed(url) self.session.add(newFeed) - FeedUpdater.FeedUpdater(self.preferences(), self.session).update(newFeed) + FeedUpdater(self.preferences(), self.session).update(newFeed) self.session.commit() except AttributeError as ae: self.session.rollback()