Mercurial > hg > Feedworm
comparison backend/couchdb/Feed.py @ 144:74217db92993
updating feeds on the couchdb backend works now
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 24 Aug 2011 11:54:06 +0200 |
parents | 2cd30af937fa |
children | b290e29a94b5 |
comparison
equal
deleted
inserted
replaced
143:f0941f42314c | 144:74217db92993 |
---|---|
1 | 1 |
2 from datetime import datetime | 2 from datetime import datetime, timedelta |
3 | 3 |
4 DATE_FORMAT = "%Y-%m-%d %H:%M:%S" | 4 DATE_FORMAT = "%Y-%m-%d %H:%M:%S" |
5 | 5 |
6 class Feed(object): | 6 class Feed(object): |
7 @staticmethod | 7 @staticmethod |
18 def needsUpdate(self): | 18 def needsUpdate(self): |
19 updateDate = self._nextUpdateDate() | 19 updateDate = self._nextUpdateDate() |
20 delta = datetime.now() - updateDate | 20 delta = datetime.now() - updateDate |
21 return delta.total_seconds() > self._updateIntervalInSeconds() | 21 return delta.total_seconds() > self._updateIntervalInSeconds() |
22 | 22 |
23 def incrementedUpdateDate(self): | |
24 updateDate = self._nextUpdateDate() | |
25 updateInterval = self._updateIntervalInSeconds() | |
26 delta = timedelta(seconds=updateInterval) | |
27 return updateDate + delta | |
28 | |
23 def _nextUpdateDate(self): | 29 def _nextUpdateDate(self): |
24 nextUpdateString = self.next_update | 30 nextUpdateString = self.next_update |
25 return datetime.strptime(nextUpdateString, DATE_FORMAT) | 31 return datetime.strptime(nextUpdateString, DATE_FORMAT) |
26 | 32 |
27 def _updateIntervalInSeconds(self): | 33 def _updateIntervalInSeconds(self): |