view backend/couchdb/Preferences.py @ 155:a05719a6175e

move common functionality into an abstract backend class, have both backends inherit from it. Implement enough of the couchdb backend that reading feeds (and marking feed entries as read) is possible
author Dirk Olmes <dirk@xanthippe.ping.de>
date Sat, 27 Aug 2011 08:52:03 +0200
parents 8ec20377bcb0
children 2d159eb2a91b
line wrap: on
line source


class Preferences(object):
    def __init__(self, database):
        self.database = database
        self.viewResults = self.database.view("feedtest/preference_by_key")

    def _valueForKey(self, key):
        try:
            resultsForKey = self.viewResults[key]
            row = iter(resultsForKey).next()
            return row.value["value"]
        except StopIteration:
            return None

    def isProxyConfigured(self):
        return self.proxyHost() is not None

    def proxyHost(self):
        return self._valueForKey("proxyHost")

    def proxyPort(self):
        return self._valueForKey("proxyPort")

    def showOnlyUnreadFeeds(self):
        return self._valueForKey("showOnlyUnreadFeeds")

    def startMaximized(self):
        return self._valueForKey("startMaximized")

    def hideReadFeedEntries(self):
        return self._valueForKey("hideReadFeedEntries")