view backend/couchdb/FeedUpdater.py @ 147:b290e29a94b5

use couchdb's mapping API instead of manually coding around Rows - much leaner code :-)
author Dirk Olmes <dirk@xanthippe.ping.de>
date Thu, 25 Aug 2011 11:05:05 +0200
parents 74217db92993
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)