summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-08-19 10:50:57 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-08-19 10:50:57 +0200
commitb7448315c76685b66a74368aa6bbfd70c5d7b531 (patch)
tree87d7d7e145dc538e1840b418454ca0f978f25eef
parent2c3a0384bd5fca829a1e7b2b0de3dcb209169052 (diff)
downloadpykolab-b7448315c76685b66a74368aa6bbfd70c5d7b531.tar.gz
Allow a URI to be passed on to connect()
-rw-r--r--pykolab/wap_client/__init__.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/pykolab/wap_client/__init__.py b/pykolab/wap_client/__init__.py
index 9549fe8..2199e9f 100644
--- a/pykolab/wap_client/__init__.py
+++ b/pykolab/wap_client/__init__.py
@@ -74,8 +74,24 @@ def authenticate(username=None, password=None, domain=None):
session_id = response['session_token']
return True
-def connect():
- global conn
+def connect(uri=None):
+ global conn, API_SSL, API_PORT, API_HOSTNAME, API_BASE
+
+ if not uri == None:
+ result = urlparse(uri)
+
+ if hasattr(result, 'scheme') and result.scheme == 'https':
+ API_SSL = True
+ API_PORT = 443
+
+ if hasattr(result, 'hostname'):
+ API_HOSTNAME = result.hostname
+
+ if hasattr(result, 'port'):
+ API_PORT = result.port
+
+ if hasattr(result, 'path'):
+ API_BASE = result.path
if conn == None:
if API_SSL: