Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab
[myslice.git] / rest / update.py
index 7b27759..f81c63e 100644 (file)
@@ -16,30 +16,36 @@ import json
 
 def dispatch(request, object_type, object_name):
     
-    o = objectRequest(request, object_type, object_name)    
-    
-    object_filters = {}
-    object_params = {}
-    result = {}
+    o = ObjectRequest(request, object_type, object_name)    
     
     if request.method == 'POST':
         req_items = request.POST
     elif request.method == 'GET':
         #return error('only post request is supported')
         req_items = request.GET
-
+    print req_items
     for el in req_items.items():
+        
+        print "#===============>",el
         if el[0].startswith('filters'):
             o.filters[el[0][8:-1]] = el[1]
         elif el[0].startswith('params'):
-            o.addParams(req_items.getlist('params[]'))
-        elif el[0].startswith('columns'):
-            o.addFilters(req_items.getlist('columns[]'))
+            print "#======> 0 ", el[0]
+            #print "#======>", el[0][7:8]
+            #print "#======>", el[0][10:-1]
+            print "#======> 1 ", el[1]
+            #o.params = req_items.getlist('params[]')
+            #o.params.append({el[0]:el[1]})
+            o.params.append({el[0][7:-1]:el[1]})
+            print "o.params = ",o.params
+            
+        elif el[0].startswith('fields'):
+            o.fields=req_items.getlist('fields[]')
         elif el[0].startswith('options'):
             o.options = req_items.getlist('options[]')
-
+    
     try:
-        response = o.execute()
+        response = o.update()
 
         if response :
             return success('record updated')
@@ -47,5 +53,5 @@ def dispatch(request, object_type, object_name):
             return error('an error has occurred')
  
     except Exception, e:
-        return error(str(e))
+        return error("exception:"+str(e))