comparison backend/couchdb/FeedUpdater.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
children b290e29a94b5
comparison
equal deleted inserted replaced
143:f0941f42314c 144:74217db92993
1
2 from FeedEntry import FeedEntry
3 from backend.AbstractFeedUpdater import AbstractFeedUpdater
4 from datetime import datetime
5 import Feed
6 import logging
7
8 log = logging.getLogger("FeedUpdater")
9
10 class FeedUpdater(AbstractFeedUpdater):
11 def __init__(self, feed, database):
12 AbstractFeedUpdater.__init__(self, feed)
13 self.database = database
14
15 def _processEntry(self, entry):
16 feedEntry = FeedEntry.findByLink(entry.link, self.database)
17 if feedEntry is None:
18 self._createFeedEntry(entry)
19
20 def _createFeedEntry(self, entry):
21 log.info("new feed entry: " + entry.title)
22 feedEntry = { "type" : "feedEntry", "feed" : self.feed._id, "link" : entry.link,
23 "title" : entry.title, "summary" : entry.summary, "read" : False,
24 "updated" : entry.updated}
25 self.database.save(feedEntry)
26
27 def _incrementFeedUpdateDate(self):
28 updateDate = self.feed.incrementedUpdateDate()
29 document = self.database.get(self.feed._id)
30 document["next_update"] = datetime.strftime(updateDate, Feed.DATE_FORMAT)
31 self.database.save(document)