# HG changeset patch # User dirk # Date 1314580085 -7200 # Node ID 2940e74c9663219ca9181d045aa6ea2059c2740b # Parent 86f828096aafe2cd168e7f94cf309fa3c8db6894 Creating a feed via the GUI works now. diff -r 86f828096aaf -r 2940e74c9663 backend/couchdb/CouchDbBackend.py --- a/backend/couchdb/CouchDbBackend.py Mon Aug 29 03:07:50 2011 +0200 +++ b/backend/couchdb/CouchDbBackend.py Mon Aug 29 03:08:05 2011 +0200 @@ -67,7 +67,7 @@ raise Exception("not yet implemented") def createFeed(self, url): - raise Exception("not yet implemented") + FeedUpdater.createFeed(url, self.database) def updateFeed(self, feed, changes): raise Exception("not yet implemented") diff -r 86f828096aaf -r 2940e74c9663 backend/couchdb/Feed.py --- a/backend/couchdb/Feed.py Mon Aug 29 03:07:50 2011 +0200 +++ b/backend/couchdb/Feed.py Mon Aug 29 03:08:05 2011 +0200 @@ -15,6 +15,13 @@ def all(database): return Feed.view(database, "feedtest/feeds") + @staticmethod + def create(url, title): + feed = Feed() + feed.rss_url = url + feed.title = title + return feed + def needsUpdate(self): delta = datetime.now() - self.next_update return delta.total_seconds() > self._updateIntervalInSeconds() diff -r 86f828096aaf -r 2940e74c9663 backend/couchdb/FeedUpdater.py --- a/backend/couchdb/FeedUpdater.py Mon Aug 29 03:07:50 2011 +0200 +++ b/backend/couchdb/FeedUpdater.py Mon Aug 29 03:08:05 2011 +0200 @@ -1,11 +1,24 @@ +from Feed import Feed from FeedEntry import FeedEntry from backend.AbstractFeedUpdater import AbstractFeedUpdater import logging +import feedparser log = logging.getLogger("FeedUpdater") class FeedUpdater(AbstractFeedUpdater): + @staticmethod + def createFeed(url, database): + feedDict = feedparser.parse(url) + if feedDict.has_key("title"): + title = feedDict["feed"].title + else: + title = url + feed = Feed.create(url, title) + feed.store(database) + FeedUpdater(feed, database).update(feedDict) + def __init__(self, feed, database): AbstractFeedUpdater.__init__(self, feed) self.database = database