X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=rest%2Fupdate.py;h=8deb42818f3653a7052ae76268aa72a57aefdc65;hb=2f20164b6a748feeef9a7dd88d901702168f380f;hp=e7b671a056ee3dbe2d10098fb328f14626dc001c;hpb=67bce829e2bac18b5b8703c54cbc61f1e4644772;p=unfold.git diff --git a/rest/update.py b/rest/update.py index e7b671a0..8deb4281 100644 --- a/rest/update.py +++ b/rest/update.py @@ -18,10 +18,6 @@ def dispatch(request, object_type, object_name): o = ObjectRequest(request, object_type, object_name) - object_filters = {} - object_params = {} - result = {} - if request.method == 'POST': req_items = request.POST elif request.method == 'GET': @@ -29,19 +25,30 @@ def dispatch(request, object_type, object_name): 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] - print o.filters elif el[0].startswith('params'): - o.params[el[0][7:-1]] = el[1] - print 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[]') elif el[0].startswith('options'): o.options = req_items.getlist('options[]') - + try: - print o.params response = o.update() if response : @@ -50,5 +57,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))