view backend/couchdb/FeedUpdater.py @ 150:babe14449162

the entries for the selected feeds had to be set onto the item delegate so had access to the selected feed entry. Keep the list in one place only (the model) and access it from the item delegate.
author Dirk Olmes <dirk@xanthippe.ping.de>
date Sat, 27 Aug 2011 06:43:28 +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)