comparison FeedUpdater.py @ 27:bdd1296a4b8c

implemented adding a feed
author Dirk Olmes <dirk@xanthippe.ping.de>
date Thu, 29 Apr 2010 06:47:47 +0200
parents e87c54b3a216
children 72dfae865899
comparison
equal deleted inserted replaced
26:f9a3223182c5 27:bdd1296a4b8c
14 try: 14 try:
15 FeedUpdater(session, feed).update() 15 FeedUpdater(session, feed).update()
16 except FeedUpdateException: 16 except FeedUpdateException:
17 logger.warn("problems while updating feed " + feed.rss_url) 17 logger.warn("problems while updating feed " + feed.rss_url)
18 session.commit() 18 session.commit()
19
20 def createNewFeed(url, session):
21 result = feedparser.parse(url)
22 title = result["feed"].title
23 newFeed = Feed(title, url)
24 session.add(newFeed)
25 session.commit()
26 FeedUpdater(newFeed).update()
27 session.commit()
19 28
20 class FeedUpdater(object): 29 class FeedUpdater(object):
21 def __init__(self, session, feed): 30 def __init__(self, session, feed):
22 self.session = session 31 self.session = session
23 self.feed = feed 32 self.feed = feed