Mercurial > hg > Feedworm
diff Feed.py @ 35:aaec263f07ca
Feeds manage the point in time when the next update should happen. FeedUpdater only updates feeds that are due.
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 05 May 2010 03:07:59 +0200 |
parents | 5bb57caa8f66 |
children | a8442c3487b5 |
line wrap: on
line diff
--- a/Feed.py Wed May 05 02:14:05 2010 +0200 +++ b/Feed.py Wed May 05 03:07:59 2010 +0200 @@ -1,4 +1,5 @@ +from datetime import datetime, timedelta import FeedEntry class Feed(object): @@ -9,6 +10,9 @@ def __init__(self, title, rss_url): self.title = title self.rss_url = rss_url + # default: update every 60 minutes + self.update_interval = 60 + self.incrementNextUpdateDate() def __repr__(self): return "<Feed (%d) %s>" % (self.pk, self.title) @@ -19,4 +23,8 @@ def entriesSortedByUpdateDate(self): sortedEntries = list(self.entries) sortedEntries.sort(FeedEntry.compareByUpdateDate) - return sortedEntries \ No newline at end of file + return sortedEntries + + def incrementNextUpdateDate(self): + delta = timedelta(minutes=self.update_interval) + self.next_update = datetime.now() + delta