Rest: fixed update with ObjectRequest
authorLoic Baron <loic.baron@lip6.fr>
Mon, 3 Mar 2014 22:42:52 +0000 (23:42 +0100)
committerLoic Baron <loic.baron@lip6.fr>
Mon, 3 Mar 2014 22:42:52 +0000 (23:42 +0100)
rest/__init__.py
rest/update.py

index 80438a2..7276d78 100644 (file)
@@ -27,6 +27,7 @@ class ObjectRequest(object):
         self.type = object_type
         self.name = object_name
         self.fields = []
+        self.params = {}
         self.filters = {}
         self.options = None
 
@@ -113,8 +114,8 @@ class ObjectRequest(object):
     def delete(self):
         query = Query.delete(self.type)
         query = self.applyFilters(query, True)
-        if self.params :
-            query.set(self.params)
+        if self.filters :
+            query.set(self.filters)
         else:
             raise Exception, "Params are required for update"
         return execute_query(self.request, query)
index 7b27759..e7b671a 100644 (file)
@@ -16,7 +16,7 @@ import json
 
 def dispatch(request, object_type, object_name):
     
-    o = objectRequest(request, object_type, object_name)    
+    o = ObjectRequest(request, object_type, object_name)    
     
     object_filters = {}
     object_params = {}
@@ -27,19 +27,22 @@ 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
     for el in req_items.items():
         if el[0].startswith('filters'):
             o.filters[el[0][8:-1]] = el[1]
+            print o.filters
         elif el[0].startswith('params'):
-            o.addParams(req_items.getlist('params[]'))
-        elif el[0].startswith('columns'):
-            o.addFilters(req_items.getlist('columns[]'))
+            o.params[el[0][7:-1]] = el[1]
+            print 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()
+        print o.params
+        response = o.update()
 
         if response :
             return success('record updated')