Mercurial > hg > Feedworm
comparison 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 |
comparison
equal
deleted
inserted
replaced
167:a3c945ce434c | 168:f4708d38419c |
---|---|
5 from datetime import datetime | 5 from datetime import datetime |
6 import logging | 6 import logging |
7 | 7 |
8 log = logging.getLogger("FeedUpdater") | 8 log = logging.getLogger("FeedUpdater") |
9 | 9 |
10 def updateAllFeeds(preferences, session): | 10 def _findFeedsToUpdate(session): |
11 allFeeds = findFeedsToUpdate(session) | |
12 for feed in allFeeds: | |
13 try: | |
14 FeedUpdater(preferences, session).update(feed) | |
15 except FeedUpdateException, fue: | |
16 log.warn("problems while updating feed " + feed.rss_url + ": " + str(fue)) | |
17 session.commit() | |
18 | |
19 def findFeedsToUpdate(session): | |
20 return session.query(Feed).filter(Feed.next_update < datetime.now()) | 11 return session.query(Feed).filter(Feed.next_update < datetime.now()) |
21 | 12 |
13 class FeedUpdater(AbstractFeedUpdater): | |
14 @staticmethod | |
15 def updateAllFeeds(preferences, session): | |
16 allFeeds = _findFeedsToUpdate(session) | |
17 for feed in allFeeds: | |
18 try: | |
19 FeedUpdater(preferences, session).update(feed) | |
20 except FeedUpdateException, fue: | |
21 log.warn("problems while updating feed " + feed.rss_url + ": " + str(fue)) | |
22 session.commit() | |
22 | 23 |
23 class FeedUpdater(AbstractFeedUpdater): | |
24 def __init__(self, preferences, session): | 24 def __init__(self, preferences, session): |
25 AbstractFeedUpdater.__init__(self, preferences) | 25 AbstractFeedUpdater.__init__(self, preferences) |
26 self.session = session | 26 self.session = session |
27 | 27 |
28 def _processEntry(self, entry): | 28 def _processEntry(self, entry): |