comparison FeedUpdater.py @ 58:dcee24702dd7

Adding a feed now logs the exception if one occurred during retrieval. More normalization of feed entries before creating new FeedEntry objects.
author Dirk Olmes <dirk@xanthippe.ping.de>
date Fri, 23 Jul 2010 17:24:32 +0200
parents 4b0d686493fb
children abc0516a1c0c
comparison
equal deleted inserted replaced
57:254d5b89a6ca 58:dcee24702dd7
52 if feedEntry is None: 52 if feedEntry is None:
53 self.createFeedEntry(entry) 53 self.createFeedEntry(entry)
54 54
55 def normalize(self, entry): 55 def normalize(self, entry):
56 if not hasattr(entry, "id"): 56 if not hasattr(entry, "id"):
57 entry.id = entry.link 57 entry.id = entry.link
58 if not hasattr(entry, "updated_parsed"):
59 entry.updated_parsed = datetime.today()
60 else:
61 entry.updated_parsed = datetime(*entry.updated_parsed[:6])
62 if not hasattr(entry, "summary"):
63 entry.summary = ""
58 64
59 def createFeedEntry(self, entry): 65 def createFeedEntry(self, entry):
60 new = FeedEntry() 66 new = FeedEntry()
61 new.id = entry.id 67 new.id = entry.id
62 new.link = entry.link 68 new.link = entry.link
63 new.title = entry.title 69 new.title = entry.title
64 new.updated = datetime(*entry.updated_parsed[:6]) 70 new.updated = entry.updated_parsed
65 new.summary = entry.summary 71 new.summary = entry.summary
66 new.feed = self.feed 72 new.feed = self.feed
67 self.session.add(new) 73 self.session.add(new)
68 74
69 class FeedUpdateException(Exception): 75 class FeedUpdateException(Exception):