comparison backend/couchdb/CouchDbBackend.py @ 174:d0ced79b5030

implement expiring read feed entries
author dirk
date Fri, 09 Sep 2011 17:21:34 +0200
parents 91a24f499318
children 57e324fa4350
comparison
equal deleted inserted replaced
173:3bcf39181f6e 174:d0ced79b5030
1 1
2 from FeedUpdater import FeedUpdater 2 from FeedUpdater import FeedUpdater
3 from Preferences import Preferences 3 from Preferences import Preferences
4 from backend.AbstractBackend import AbstractBackend 4 from backend.AbstractBackend import AbstractBackend
5 from backend.couchdb import CouchDb
5 from backend.couchdb.Feed import Feed 6 from backend.couchdb.Feed import Feed
6 from backend.couchdb.FeedEntry import FeedEntry 7 from backend.couchdb.FeedEntry import FeedEntry
7 import couchdb 8 import couchdb
8 from backend.couchdb import CouchDb 9 import logging
9 10
10 class CouchDbBackend(AbstractBackend): 11 class CouchDbBackend(AbstractBackend):
11 ''' 12 '''
12 Backend that uses CouchDB for persistence 13 Backend that uses CouchDB for persistence
13 ''' 14 '''
99 for feed in allFeeds: 100 for feed in allFeeds:
100 if feed.needsUpdate(): 101 if feed.needsUpdate():
101 FeedUpdater(self.database, self.preferences()).update(feed) 102 FeedUpdater(self.database, self.preferences()).update(feed)
102 103
103 def expireFeedEntries(self): 104 def expireFeedEntries(self):
104 print("Expiring feeds is not yet implemented") 105 logger = logging.getLogger("expiry")
105 # raise Exception("not yet implemented") 106 expireDate = self._calculateExpireDate()
106 107 logger.info("expiring entries older than " + str(expireDate))
108 for entry in FeedEntry.getReadFeedEntriesOlderThan(expireDate, self.database):
109 del self.database[entry.id]