X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=rest%2F__init__.py;h=98b9d085baa792848f6daa888877dff647203c0b;hb=0db92b43925f7f7fb76fcdd64bc6bb982bcd0771;hp=bdf3ee0812d241bd91cb9d88bb72fd91f7f6da4d;hpb=ac3dbfec87815247c7bfbf438ff266f6ef25d27b;p=myslice.git 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: