Mercurial > hg > Feedworm
view backend/couchdb/FeedUpdater.py @ 146:8ec20377bcb0
move getting the entries for a feed to the backend so that the couchdb backend can use a custom view for feed entries
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Thu, 25 Aug 2011 07:01:45 +0200 |
parents | 74217db92993 |
children | b290e29a94b5 |
line wrap: on
line source
from FeedEntry import FeedEntry from backend.AbstractFeedUpdater import AbstractFeedUpdater from datetime import datetime import Feed import logging log = logging.getLogger("FeedUpdater") class FeedUpdater(AbstractFeedUpdater): def __init__(self, feed, database): AbstractFeedUpdater.__init__(self, feed) self.database = database def _processEntry(self, entry): feedEntry = FeedEntry.findByLink(entry.link, self.database) if feedEntry is None: self._createFeedEntry(entry) def _createFeedEntry(self, entry): log.info("new feed entry: " + entry.title) feedEntry = { "type" : "feedEntry", "feed" : self.feed._id, "link" : entry.link, "title" : entry.title, "summary" : entry.summary, "read" : False, "updated" : entry.updated} self.database.save(feedEntry) def _incrementFeedUpdateDate(self): updateDate = self.feed.incrementedUpdateDate() document = self.database.get(self.feed._id) document["next_update"] = datetime.strftime(updateDate, Feed.DATE_FORMAT) self.database.save(document)