translate most modules to using print() as imported from __future__
[unfold.git] / rest / update.py
index f81c63e..99d668d 100644 (file)
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
 from django.views.generic.base      import TemplateView
 from django.shortcuts               import render_to_response
 
@@ -23,21 +25,25 @@ def dispatch(request, object_type, object_name):
     elif request.method == 'GET':
         #return error('only post request is supported')
         req_items = request.GET
-    print req_items
+    print(req_items)
     for el in req_items.items():
         
-        print "#===============>",el
+        print("#===============>",el)
         if el[0].startswith('filters'):
             o.filters[el[0][8:-1]] = el[1]
         elif el[0].startswith('params'):
-            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
+            print("#======> 0 ", el[0])
+            print("#======> 1 ", req_items.getlist(el[0]))
+
+            if (el[0][-2:] == '[]') :
+                # when receiving params[key][] = 'value1' ...
+                #o.params.append({el[0][7:-3]:",".join(req_items.getlist(el[0]))})
+                o.params.append({el[0][7:-3]:req_items.getlist(el[0])})
+            else :
+                # when receiving params[key] = 'value'
+                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[]')