diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2014-08-19 10:50:57 +0200 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2014-08-19 10:50:57 +0200 |
commit | b7448315c76685b66a74368aa6bbfd70c5d7b531 (patch) | |
tree | 87d7d7e145dc538e1840b418454ca0f978f25eef /pykolab/wap_client/__init__.py | |
parent | 2c3a0384bd5fca829a1e7b2b0de3dcb209169052 (diff) | |
download | pykolab-b7448315c76685b66a74368aa6bbfd70c5d7b531.tar.gz |
Allow a URI to be passed on to connect()
Diffstat (limited to 'pykolab/wap_client/__init__.py')
-rw-r--r-- | pykolab/wap_client/__init__.py | 20 |
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: |