From f1cf6a4b262f202c141d0e7cdd90f0f8403f9f5d Mon Sep 17 00:00:00 2001 From: drebs Date: Tue, 30 Apr 2013 12:13:07 -0300 Subject: Fix shared db auth and add tests. --- src/leap/soledad/backends/couch.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/leap/soledad/backends/couch.py') diff --git a/src/leap/soledad/backends/couch.py b/src/leap/soledad/backends/couch.py index 95090510..4dcea3f8 100644 --- a/src/leap/soledad/backends/couch.py +++ b/src/leap/soledad/backends/couch.py @@ -387,7 +387,8 @@ class CouchDatabase(ObjectStoreDatabase): indexes = {} for name, idx in self._indexes.iteritems(): indexes[name] = {} - for attr in [INDEX_NAME_KEY, INDEX_DEFINITION_KEY, INDEX_VALUES_KEY]: + for attr in [self.INDEX_NAME_KEY, self.INDEX_DEFINITION_KEY, + self.INDEX_VALUES_KEY]: indexes[name][attr] = getattr(idx, '_' + attr) return json.dumps(indexes) @@ -404,8 +405,8 @@ class CouchDatabase(ObjectStoreDatabase): """ dict = {} for name, idx_dict in json.loads(indexes).iteritems(): - idx = InMemoryIndex(name, idx_dict[INDEX_DEFINITION_KEY]) - idx._values = idx_dict[INDEX_VALUES_KEY] + idx = InMemoryIndex(name, idx_dict[self.INDEX_DEFINITION_KEY]) + idx._values = idx_dict[self.INDEX_VALUES_KEY] dict[name] = idx return dict @@ -435,8 +436,9 @@ class CouchServerState(ServerState): @rtype: CouchDatabase """ # TODO: open couch - return CouchDatabase.open_database(self.couch_url + '/' + dbname, - create=False) + return CouchDatabase.open_database( + self.couch_url + '/' + dbname, + create=False) def ensure_database(self, dbname): """ @@ -448,8 +450,9 @@ class CouchServerState(ServerState): @return: The CouchDatabase object and the replica uid. @rtype: (CouchDatabase, str) """ - db = CouchDatabase.open_database(self.couch_url + '/' + dbname, - create=True) + db = CouchDatabase.open_database( + self.couch_url + '/' + dbname, + create=True) return db, db._replica_uid def delete_database(self, dbname): -- cgit v1.2.3