Mercurial > hg > Feedworm
diff backend/couchdb/CouchDbBackend.py @ 169:91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
author | dirk |
---|---|
date | Fri, 09 Sep 2011 14:52:54 +0200 |
parents | 04c3b9796b89 |
children | d0ced79b5030 |
line wrap: on
line diff
--- a/backend/couchdb/CouchDbBackend.py Mon Sep 05 19:43:34 2011 +0200 +++ b/backend/couchdb/CouchDbBackend.py Fri Sep 09 14:52:54 2011 +0200 @@ -5,8 +5,7 @@ from backend.couchdb.Feed import Feed from backend.couchdb.FeedEntry import FeedEntry import couchdb - -DATABASE = "feedtest" +from backend.couchdb import CouchDb class CouchDbBackend(AbstractBackend): ''' @@ -14,8 +13,9 @@ ''' def __init__(self): + CouchDb.init() server = couchdb.Server() - self.database = server[DATABASE] + self.database = server[CouchDb.database] self.prefs = None def preferences(self): @@ -41,7 +41,7 @@ def _retrieveEntriesForSelectedFeed(self, hideReadEntries): # TODO how to hide read entries if requested? - viewResults = FeedEntry.view(self.database, "feedtest/feedEntries_by_feed", + viewResults = FeedEntry.view(self.database, CouchDb.feedEntriesByFeed(), key=self.selectedFeed.id) return list(viewResults) @@ -77,15 +77,15 @@ feed.store(self.database) def deleteSelectedFeed(self): - viewResults = self.database.view("feedtest/feedEntries_by_feed", key=self.selectedFeed.id) + viewResults = self.database.view(CouchDb.feedEntriesByFeed(), key=self.selectedFeed.id) for row in viewResults: del self.database[row.id] del self.database[self.selectedFeed.id] def entriesForFeed(self, feed, hideReadEntries): - viewName = "feedtest/feedEntries_by_feed" + viewName = CouchDb.feedEntriesByFeed() if hideReadEntries: - viewName = "feedtest/unread_feedEntries_by_feed" + viewName = CouchDb.unreadFeedEntriesByFeed() return list(FeedEntry.view(self.database, viewName)) def markFeedEntriesAsRead(self, indices):