Mercurial > hg > Feedworm
diff backend/sqlalchemy/FeedUpdater.py @ 123:862760b161b4 backend
restructured adding a feed so that only the URL is passed into the backend - the rest of the operation is backend-internal
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Mon, 22 Aug 2011 10:30:33 +0200 |
parents | 510a5d00e98a |
children | 6ea813cfac33 |
line wrap: on
line diff
--- a/backend/sqlalchemy/FeedUpdater.py Sun Aug 21 18:39:02 2011 +0200 +++ b/backend/sqlalchemy/FeedUpdater.py Mon Aug 22 10:30:33 2011 +0200 @@ -33,24 +33,24 @@ else: entry.summary = "" +def createNewFeed(url, session): + # when updating to python3 see http://code.google.com/p/feedparser/issues/detail?id=260 + result = feedparser.parse(url) + if result.has_key("title"): + title = result["feed"].title + else: + title = url + newFeed = Feed(title, url) + session.add(newFeed) + + FeedUpdater(session, newFeed).update() + + class FeedUpdater(object): def __init__(self, session, feed): self.session = session self.feed = feed - # TODO this is a HACK! creating new instances from itself is bad but required due to the storage of the session. - def createNewFeed(self, url): - # when updating to python3 see http://code.google.com/p/feedparser/issues/detail?id=260 - result = feedparser.parse(url) - if result.has_key("title"): - title = result["feed"].title - else: - title = url - newFeed = Feed(title, url) - self.session.add(newFeed) - - FeedUpdater(self.session, newFeed).update() - def update(self): log.info("updating " + self.feed.rss_url) result = self.getFeed()