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