diff 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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backend/couchdb/Preferences.py	Tue Aug 23 03:44:08 2011 +0200
@@ -0,0 +1,22 @@
+
+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")