# HG changeset patch # User Dirk Olmes # Date 1314063848 -7200 # Node ID 9e1e6b96d8b04315de9b10db5cf908a207fefdce # Parent 63d6d60d37ffe303854a2e66694d4ee28fa6e70b implement proxyHost/proxyPort in Preferences diff -r 63d6d60d37ff -r 9e1e6b96d8b0 backend/couchdb/CouchDbBackend.py --- a/backend/couchdb/CouchDbBackend.py Mon Aug 22 19:51:59 2011 +0200 +++ b/backend/couchdb/CouchDbBackend.py Tue Aug 23 03:44:08 2011 +0200 @@ -1,6 +1,9 @@ +from Preferences import Preferences import couchdb +DATABASE = "feedtest" + class CouchDbBackend(object): ''' Backend that uses CouchDB for persistence @@ -8,10 +11,10 @@ def __init__(self): server = couchdb.Server() - self.database = server["feedtest"] + self.database = server[DATABASE] def preferences(self): - raise Exception("not yet implemented") + return Preferences(self.database) def getFeeds(self): raise Exception("not yet implemented") diff -r 63d6d60d37ff -r 9e1e6b96d8b0 backend/couchdb/Preferences.py --- /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") diff -r 63d6d60d37ff -r 9e1e6b96d8b0 feedworm-gui.py --- a/feedworm-gui.py Mon Aug 22 19:51:59 2011 +0200 +++ b/feedworm-gui.py Tue Aug 23 03:44:08 2011 +0200 @@ -3,6 +3,7 @@ from PyQt4 import QtGui from PyQt4.QtNetwork import QNetworkProxy from backend.sqlalchemy.SqlAlchemyBackend import SqlAlchemyBackend +from backend.couchdb.CouchDbBackend import CouchDbBackend import logging import sys @@ -15,7 +16,8 @@ if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) - backend = SqlAlchemyBackend() +# backend = SqlAlchemyBackend() + backend = CouchDbBackend() preferences = backend.preferences() setupProxy(preferences)