From: Loic Baron Date: Thu, 27 Mar 2014 10:34:11 +0000 (+0100) Subject: Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab X-Git-Tag: myslice-1.1~172^2 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=11b83a3dc742c2f139c67ced00dcca10713a9602;hp=b577b69d1d713e3b38d1d19e811a4b89fad9fcbf;p=myslice.git Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab --- diff --git a/rest/__init__.py b/rest/__init__.py index bdf3ee08..98b9d085 100644 --- a/rest/__init__.py +++ b/rest/__init__.py @@ -40,10 +40,24 @@ class ObjectRequest(object): self.filters['disabled'] = '0' self.filters['gateway_type'] = 'sfa' self.filters['platform'] = '!myslice' + elif(self.type.startswith('local:')): + # XXX TODO: find a generic Query to get the fields like + # select column.name from local:object where table == local:user + table = self.type.split(':') + table = table[1] + if table == "user": + self.id = table + '_id' + self.fields = ['user_id', 'email', 'password', 'config','status']; + elif table == "account": + # XXX TODO: Multiple key for account = (platform_id, user_id) + self.id = None + self.fields = ['platform_id', 'user_id', 'auth_type', 'config']; + elif table == "platform": + self.id = 'platform' + self.fields = ['platform', 'platform_longname', 'platform_url', 'platform_description','gateway_type']; else : self.setKey() self.setLocalFields() - def setKey(self): # What about key formed of multiple fields??? @@ -94,7 +108,7 @@ class ObjectRequest(object): def get(self): query = Query.get(self.type) - if (self.id not in self.fields) : + if (self.id is not None) and (self.id not in self.fields) : query.select(self.fields + [self.id]) else : query.select(self.fields) @@ -114,10 +128,14 @@ class ObjectRequest(object): def update(self): query = Query.update(self.type) query = self.applyFilters(query, True) - print ">>>>>",self.params + + print "rest/__init__ self = ",self + print "rest/__init__ params = ",self.params if self.params : - query.set({ 'resource' : self.params}) + print "query = ",query + query.set(self.params) +# query.set({ 'resource' : self.params}) # for param in self.params : else: diff --git a/rest/create.py b/rest/create.py index e95a6e76..afb62b74 100644 --- a/rest/create.py +++ b/rest/create.py @@ -29,7 +29,8 @@ def dispatch(request, object_type, object_name): if el[0].startswith('filters'): o.filters[el[0][8:-1]] = el[1] elif el[0].startswith('params'): - o.params[el[0][7:-1]] = el[1] + #o.params[el[0][7:-1]] = el[1] + o.params.append({el[0][7:-1]:el[1]}) elif el[0].startswith('fields'): o.fields=req_items.getlist('fields[]') elif el[0].startswith('options'): diff --git a/rest/update.py b/rest/update.py index d2dd71e7..f81c63e8 100644 --- a/rest/update.py +++ b/rest/update.py @@ -34,8 +34,10 @@ def dispatch(request, object_type, object_name): #print "#======>", el[0][7:8] #print "#======>", el[0][10:-1] print "#======> 1 ", el[1] - o.params = req_items.getlist('params[]') - + #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[]') @@ -51,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))