view backend/couchdb/Preferences.py @ 133:9e1e6b96d8b0

implement proxyHost/proxyPort in Preferences
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 23 Aug 2011 03:44:08 +0200
parents
children 8ec20377bcb0
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")