annotate backend/couchdb/FeedUpdater.py @ 185:0b4c8dc13b7c

when replicating pull from remote first
author dirk
date Mon, 12 Sep 2011 11:07:58 +0200
parents 04c3b9796b89
children a9ba3e3a9a9a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
144
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
1
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
2 from FeedEntry import FeedEntry
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
3 from backend.AbstractFeedUpdater import AbstractFeedUpdater
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
4 import logging
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
5
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
6 log = logging.getLogger("FeedUpdater")
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
7
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
8 class FeedUpdater(AbstractFeedUpdater):
166
04c3b9796b89 feedparser uses the proxy now if one is configured. To implement this the FeedUpdater had to change a bit - sqlalchemy backend is not yet refactored.
dirk
parents: 161
diff changeset
9 def __init__(self, database, preferences):
04c3b9796b89 feedparser uses the proxy now if one is configured. To implement this the FeedUpdater had to change a bit - sqlalchemy backend is not yet refactored.
dirk
parents: 161
diff changeset
10 AbstractFeedUpdater.__init__(self, preferences)
144
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
11 self.database = database
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13 def _processEntry(self, entry):
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
14 feedEntry = FeedEntry.findByLink(entry.link, self.database)
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
15 if feedEntry is None:
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
16 self._createFeedEntry(entry)
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
17
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
18 def _createFeedEntry(self, entry):
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
19 log.info("new feed entry: " + entry.title)
147
b290e29a94b5 use couchdb's mapping API instead of manually coding around Rows - much leaner code :-)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 144
diff changeset
20 feedEntry = FeedEntry()
b290e29a94b5 use couchdb's mapping API instead of manually coding around Rows - much leaner code :-)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 144
diff changeset
21 feedEntry.feed = self.feed.id
b290e29a94b5 use couchdb's mapping API instead of manually coding around Rows - much leaner code :-)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 144
diff changeset
22 feedEntry.link = entry.link
b290e29a94b5 use couchdb's mapping API instead of manually coding around Rows - much leaner code :-)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 144
diff changeset
23 feedEntry.title = entry.title
b290e29a94b5 use couchdb's mapping API instead of manually coding around Rows - much leaner code :-)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 144
diff changeset
24 feedEntry.summary = entry.summary
b290e29a94b5 use couchdb's mapping API instead of manually coding around Rows - much leaner code :-)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 144
diff changeset
25 feedEntry.updated = entry.updated_parsed
b290e29a94b5 use couchdb's mapping API instead of manually coding around Rows - much leaner code :-)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 144
diff changeset
26 feedEntry.store(self.database)
144
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
27
74217db92993 updating feeds on the couchdb backend works now
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
28 def _incrementFeedUpdateDate(self):
147
b290e29a94b5 use couchdb's mapping API instead of manually coding around Rows - much leaner code :-)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 144
diff changeset
29 self.feed.incrementNextUpdateDate()
b290e29a94b5 use couchdb's mapping API instead of manually coding around Rows - much leaner code :-)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 144
diff changeset
30 self.feed.store(self.database)
166
04c3b9796b89 feedparser uses the proxy now if one is configured. To implement this the FeedUpdater had to change a bit - sqlalchemy backend is not yet refactored.
dirk
parents: 161
diff changeset
31
04c3b9796b89 feedparser uses the proxy now if one is configured. To implement this the FeedUpdater had to change a bit - sqlalchemy backend is not yet refactored.
dirk
parents: 161
diff changeset
32 def _setFeedTitle(self, feedDict):
04c3b9796b89 feedparser uses the proxy now if one is configured. To implement this the FeedUpdater had to change a bit - sqlalchemy backend is not yet refactored.
dirk
parents: 161
diff changeset
33 oldTitle = self.feed.title
04c3b9796b89 feedparser uses the proxy now if one is configured. To implement this the FeedUpdater had to change a bit - sqlalchemy backend is not yet refactored.
dirk
parents: 161
diff changeset
34 AbstractFeedUpdater._setFeedTitle(self, feedDict)
04c3b9796b89 feedparser uses the proxy now if one is configured. To implement this the FeedUpdater had to change a bit - sqlalchemy backend is not yet refactored.
dirk
parents: 161
diff changeset
35 if oldTitle != self.feed.title:
04c3b9796b89 feedparser uses the proxy now if one is configured. To implement this the FeedUpdater had to change a bit - sqlalchemy backend is not yet refactored.
dirk
parents: 161
diff changeset
36 self.feed.store(self.database)