summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/leap/__init__.py (renamed from leap/__init__.py)8
-rw-r--r--src/leap/mx/__init__.py0
-rw-r--r--src/leap/mx/alias_resolver.py (renamed from leap/mx/alias_resolver.py)35
-rw-r--r--src/leap/util/__init__.py0
-rw-r--r--src/leap/util/net.py (renamed from leap/util/net.py)0
-rw-r--r--src/leap/util/version.py (renamed from leap/util/version.py)0
6 files changed, 39 insertions, 4 deletions
diff --git a/leap/__init__.py b/src/leap/__init__.py
index 370676e..5fefbbf 100644
--- a/leap/__init__.py
+++ b/src/leap/__init__.py
@@ -1,9 +1,9 @@
# -*- encoding: utf-8 -*-
-from . import mx
-from . import util
-from . import tests
+from leap import mx
+from leap import util
+from leap import tests
+__all__ = ['mx', 'util', 'tests']
__author__ = util.version.authors
__version__ = util.version.getVersion()
-__all__ = ['mx', 'util', 'tests']
diff --git a/src/leap/mx/__init__.py b/src/leap/mx/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/leap/mx/__init__.py
diff --git a/leap/mx/alias_resolver.py b/src/leap/mx/alias_resolver.py
index 5010f63..3d20ff7 100644
--- a/leap/mx/alias_resolver.py
+++ b/src/leap/mx/alias_resolver.py
@@ -35,6 +35,9 @@ class ConnectedCouchDB(client.CouchDB):
Connect to a CouchDB instance.
## xxx will we need to open CouchDB documents and views?
+ ## yes, these are in a _design document
+ ##
+
"""
def __init__(self, host, port, dbName=None,
username=None, password=None, *args, **kwargs):
@@ -54,6 +57,38 @@ class ConnectedCouchDB(client.CouchDB):
username=username,
password=password,
*args, **kwargs)
+ if dbName:
+ self.bindToDB(dbName)
+ else:
+ databases = self.listDB()
+ log.msg("Available databases: %s" % databases)
+
+ def queryByEmailOrAlias(self, alias, dbDoc="User",
+ view="by_email_or_alias"):
+ """
+ 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.
+ """
+ assert isinstance(alias, str), "Email or alias queries must be string"
+
+ ## Prepend a forward slash, in case we forgot it:
+ if not alias.startswith('/'):
+ alias = '/' + alias
+
+ d = self.openDoc(dbDoc)
+ d.addCallbacks(self.openView, log.err, (view))
+ d.addCallbacks(self.get, log.err, (alias))
+ d.addCallbacks(self.parseResult, log.err)
+
+ @d.addCallback
+ def show_answer(result):
+ log.msg("Query: %s" % alias)
+ log.msg("Answer: %s" % alias)
+
+ return d
def query(self, uri):
"""
diff --git a/src/leap/util/__init__.py b/src/leap/util/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/leap/util/__init__.py
diff --git a/leap/util/net.py b/src/leap/util/net.py
index a4104d0..a4104d0 100644
--- a/leap/util/net.py
+++ b/src/leap/util/net.py
diff --git a/leap/util/version.py b/src/leap/util/version.py
index ecf8a22..ecf8a22 100644
--- a/leap/util/version.py
+++ b/src/leap/util/version.py