view backend/couchdb/FeedUpdater.py @ 148:c5a427d46703

displaying entries for a feed works now with the couchdb backend
author Dirk Olmes <dirk@xanthippe.ping.de>
date Fri, 26 Aug 2011 06:13:39 +0200
parents b290e29a94b5
children 2940e74c9663
line wrap: on
line source


from FeedEntry import FeedEntry
from backend.AbstractFeedUpdater import AbstractFeedUpdater
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 = FeedEntry()
        feedEntry.feed = self.feed.id
        feedEntry.link = entry.link
        feedEntry.title = entry.title
        feedEntry.summary = entry.summary
        feedEntry.updated = entry.updated_parsed
        feedEntry.store(self.database)

    def _incrementFeedUpdateDate(self):
        self.feed.incrementNextUpdateDate()
        self.feed.store(self.database)