Mercurial > hg > Feedworm
view backend/couchdb/CouchDbBackend.py @ 148:c5a427d46703
displaying entries for a feed works now with the couchdb backend
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Fri, 26 Aug 2011 06:13:39 +0200 |
parents | 8ec20377bcb0 |
children | a05719a6175e |
line wrap: on
line source
from FeedUpdater import FeedUpdater from Preferences import Preferences from backend.couchdb.Feed import Feed from backend.couchdb.FeedEntry import FeedEntry import couchdb DATABASE = "feedtest" class CouchDbBackend(object): ''' Backend that uses CouchDB for persistence ''' def __init__(self): server = couchdb.Server() self.database = server[DATABASE] def preferences(self): return Preferences(self.database) def getFeeds(self): if self.preferences().showOnlyUnreadFeeds(): return self._getUnreadFeeds() else: # make sure that the results are actually fetched into memory, otherwise we'll pass # a ViewResults instance around which is not what we want return list(Feed.all(self.database)) def _getUnreadFeeds(self): raise Exception("not yet implemented") def toggleRead(self, feedEntry): raise Exception("not yet implemented") def markAllEntriesRead(self, feed): raise Exception("not yet implemented") def createFeed(self, url): raise Exception("not yet implemented") def updateFeed(self, feed, changes): raise Exception("not yet implemented") def deleteFeed(self, feed): raise Exception("not yet implemented") def entriesForFeed(self, feed, hideReadEntries): viewName = "feedtest/feedEntries_by_feed" if hideReadEntries: viewName = "feedtest/unread_feedEntries_by_feed" return list(FeedEntry.view(self.database, viewName)) def markFeedEntriesAsRead(self, entries): raise Exception("not yet implemented") def updateAllFeeds(self): # TODO use a view instead of iterating all feeds allFeeds = Feed.all(self.database) for feed in allFeeds: if feed.needsUpdate(): FeedUpdater(feed, self.database).update() def expireFeedEntries(self): print("Expiring feeds is not yet implemented") # raise Exception("not yet implemented") def dispose(self): # nothing to do here pass