From f69a085cfe9d904404cb421e802515b716cfbf9c Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Mon, 15 Apr 2013 19:50:23 +0000 Subject: Update couchdb.ConnectedCouchDB class docstring. --- src/leap/mx/couchdb.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/leap/mx/couchdb.py') diff --git a/src/leap/mx/couchdb.py b/src/leap/mx/couchdb.py index b5d4127..c020295 100644 --- a/src/leap/mx/couchdb.py +++ b/src/leap/mx/couchdb.py @@ -26,11 +26,10 @@ from leap.mx.util import log class ConnectedCouchDB(client.CouchDB): - """ - Connect to a CouchDB instance. + """Connect to a CouchDB instance. - ## xxx will we need to open CouchDB documents and views? - ## yes, these are in a _design document + CouchDB document for testing is '_design', and the view is simply + a preconfigured set of mapped responses. """ def __init__(self, host, port, dbName=None, username=None, password=None, *args, **kwargs): -- cgit v1.2.3 From 07488a8d4c4aea1f7c86cd13219ee37ec8b46850 Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Mon, 15 Apr 2013 19:50:50 +0000 Subject: Add default CouchDB port to couchdb.ConnectCouchDB parameters. --- src/leap/mx/couchdb.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/leap/mx/couchdb.py') diff --git a/src/leap/mx/couchdb.py b/src/leap/mx/couchdb.py index c020295..f63d2f0 100644 --- a/src/leap/mx/couchdb.py +++ b/src/leap/mx/couchdb.py @@ -31,7 +31,7 @@ class ConnectedCouchDB(client.CouchDB): CouchDB document for testing is '_design', and the view is simply a preconfigured set of mapped responses. """ - def __init__(self, host, port, dbName=None, username=None, + def __init__(self, host, port=5984, dbName=None, username=None, password=None, *args, **kwargs): """ Connect to a CouchDB instance. @@ -44,7 +44,8 @@ class ConnectedCouchDB(client.CouchDB): @returns: A :class:`twisted.internet.defer.Deferred` representing the the client connection to the CouchDB instance. """ - super(client.CouchDB, self).__init__(host, port, + super(client.CouchDB, self).__init__(host, + port=port, dbName=dbName, username=username, password=password, -- cgit v1.2.3 From 368f03896aaf88249805b5ae2484c67d8fe73d74 Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Mon, 15 Apr 2013 19:52:29 +0000 Subject: Update ConnectedCouchDB.__init__() docstring. --- src/leap/mx/couchdb.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/leap/mx/couchdb.py') diff --git a/src/leap/mx/couchdb.py b/src/leap/mx/couchdb.py index f63d2f0..e7aee8b 100644 --- a/src/leap/mx/couchdb.py +++ b/src/leap/mx/couchdb.py @@ -36,12 +36,12 @@ class ConnectedCouchDB(client.CouchDB): """ Connect to a CouchDB instance. - @param host: A hostname string for the CouchDB server. - @param port: The port of the CouchDB server, as an integer. - @param dbName: (optional) The default database to connect to. - @param username: (optional) The username for authorization. - @param password: (optional) The password for authorization. - @returns: A :class:`twisted.internet.defer.Deferred` representing the + :param str host: A hostname string for the CouchDB server. + :param int port: The port of the CouchDB server. + :param str dbName: (optional) The default database to bind queries to. + :param str username: (optional) The username for authorization. + :param str password: (optional) The password for authorization. + :returns: A :class:`twisted.internet.defer.Deferred` representing the the client connection to the CouchDB instance. """ super(client.CouchDB, self).__init__(host, -- cgit v1.2.3 From 9a166f7cd1247e022ca2f0b5685e927f3d0edfca Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Mon, 15 Apr 2013 19:53:04 +0000 Subject: Remove duplicate call to bind database, it's in the super() call. --- src/leap/mx/couchdb.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/leap/mx/couchdb.py') diff --git a/src/leap/mx/couchdb.py b/src/leap/mx/couchdb.py index e7aee8b..826e83e 100644 --- a/src/leap/mx/couchdb.py +++ b/src/leap/mx/couchdb.py @@ -50,9 +50,7 @@ class ConnectedCouchDB(client.CouchDB): username=username, password=password, *args, **kwargs) - if dbName: - self.bindToDB(dbName) - else: + if dbName is None: databases = self.listDB() log.msg("Available databases: %s" % databases) -- cgit v1.2.3 From 6e97e1f509025569979153542aa2362bb7c2f413 Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Mon, 15 Apr 2013 19:53:39 +0000 Subject: Override parent CouchDB methods for database creation and deletion. --- src/leap/mx/couchdb.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/leap/mx/couchdb.py') diff --git a/src/leap/mx/couchdb.py b/src/leap/mx/couchdb.py index 826e83e..9b69091 100644 --- a/src/leap/mx/couchdb.py +++ b/src/leap/mx/couchdb.py @@ -54,6 +54,14 @@ class ConnectedCouchDB(client.CouchDB): databases = self.listDB() log.msg("Available databases: %s" % databases) + def createDB(self, dbName): + """Overrides ``paisley.client.CouchDB.createDB``.""" + pass + + def deleteDB(self, dbName): + """Overrides ``paisley.client.CouchDB.deleteDB``.""" + pass + def queryByEmailOrAlias(self, alias, dbDoc="User", view="by_email_or_alias"): """ -- cgit v1.2.3 From 5048af81ffea65f9abc8d9aae451a58f97e015fd Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Mon, 15 Apr 2013 19:54:14 +0000 Subject: Update ConnectedCouchDB.queryByEmailOrAlias() docstring. --- src/leap/mx/couchdb.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/leap/mx/couchdb.py') diff --git a/src/leap/mx/couchdb.py b/src/leap/mx/couchdb.py index 9b69091..fb4d8f6 100644 --- a/src/leap/mx/couchdb.py +++ b/src/leap/mx/couchdb.py @@ -64,12 +64,11 @@ class ConnectedCouchDB(client.CouchDB): def queryByEmailOrAlias(self, alias, dbDoc="User", view="by_email_or_alias"): - """ - Check to see if a particular email or alias exists. + """Check to see if a particular email or alias exists. - @param alias: A string representing the email or alias to check. - @param dbDoc: The CouchDB document to open. - @param view: The view of the CouchDB document to use. + :param str alias: A string representing the email or alias to check. + :param str dbDoc: The CouchDB document to open. + :param str view: The view of the CouchDB document to use. """ assert isinstance(alias, str), "Email or alias queries must be string" -- cgit v1.2.3 From a0cdd89a1e74f61c263bd7ee4b214d823b8e3a7c Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Mon, 15 Apr 2013 19:54:54 +0000 Subject: Update ConnectedCouchDB.query() docstring. --- src/leap/mx/couchdb.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/leap/mx/couchdb.py') diff --git a/src/leap/mx/couchdb.py b/src/leap/mx/couchdb.py index fb4d8f6..fe46ac6 100644 --- a/src/leap/mx/couchdb.py +++ b/src/leap/mx/couchdb.py @@ -89,8 +89,10 @@ class ConnectedCouchDB(client.CouchDB): return d def query(self, uri): - """ - Query a CouchDB instance that we are connected to. + """Query a CouchDB instance that we are connected to. + + :param str uri: A particular URI in the CouchDB, i.e. + "/users/_design/User/_view/by_email_or_alias". """ try: self.checkURI(uri) ## xxx write checkURI() -- cgit v1.2.3 From 471c584b4fac9de68200f3b252292f1735f3d1a4 Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Mon, 15 Apr 2013 19:55:19 +0000 Subject: Update ConnectedCouchDB.listUsersAndEmails() docstring. --- src/leap/mx/couchdb.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/leap/mx/couchdb.py') diff --git a/src/leap/mx/couchdb.py b/src/leap/mx/couchdb.py index fe46ac6..04cfc4d 100644 --- a/src/leap/mx/couchdb.py +++ b/src/leap/mx/couchdb.py @@ -109,12 +109,14 @@ class ConnectedCouchDB(client.CouchDB): @defer.inlineCallbacks def listUsersAndEmails(self, limit=1000, reverse=False): - """ - List all users and email addresses, up to the given limit. + """List all users and email addresses, up to the given limit. + + :param int limit: The number of results to limit the response to. + :param bool reverse: Start at the end of the database mapping. """ query = "/users/_design/User/_view/by_email_or_alias/?reduce=false" answer = yield self.query(query, limit=limit, reverse=reverse) - + if answer: parsed = yield self.parseResult(answer) if parsed: -- cgit v1.2.3