summaryrefslogtreecommitdiffstats
path: root/pykolab/wap_client/__init__.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-08-03 20:10:46 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-08-03 20:10:46 +0100
commit1a75eb26893928bebcb258da49ebed0d9052be56 (patch)
tree7a0e57e2a7eb1c9844177919fa16bcfcb201c344 /pykolab/wap_client/__init__.py
parent7e4e391a82a19a587173cf85f1efb01905c56238 (diff)
downloadpykolab-1a75eb26893928bebcb258da49ebed0d9052be56.tar.gz
Add user_find method and do not traceback when the result is not OK
Diffstat (limited to 'pykolab/wap_client/__init__.py')
-rw-r--r--pykolab/wap_client/__init__.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/pykolab/wap_client/__init__.py b/pykolab/wap_client/__init__.py
index 9274be3..1dd6aab 100644
--- a/pykolab/wap_client/__init__.py
+++ b/pykolab/wap_client/__init__.py
@@ -292,7 +292,8 @@ def request(method, api_uri, get=None, post=None, headers={}):
del response_data['status']
return response_data['result']
else:
- return response_data['result']
+ print "ERROR: %r" % (response_data['reason'])
+ return False
def request_raw(method, api_uri, get=None, post=None, headers={}):
global session_id
@@ -383,6 +384,30 @@ def user_edit(user = None, attributes={}):
return user_edit
+def user_find(attribs=None):
+ if attribs == None:
+ post = {
+ 'search': {
+ 'params': {
+ utils.ask_question("Attribute") : {
+ 'value': utils.ask_question("value"),
+ 'type': 'exact'
+ }
+ }
+ }
+ }
+ else:
+ post = { 'search': { 'params': {} } }
+
+ for (k,v) in attribs.iteritems():
+ post['search']['params'][k] = { 'value': v, 'type': 'exact' }
+
+ post = json.dumps(post)
+
+ user = request('POST', 'user.find', post=post)
+
+ return user
+
def user_form_value_generate(params=None):
if params == None:
params = get_user_input()