@@ -50,7 +50,7 @@ def get_collection(self, class_name, input):
5050 raise Unauthorised ('Permission to view %s denied' % class_name )
5151 class_obj = self .db .getclass (class_name )
5252 prop_name = class_obj .labelprop ()
53- result = [{'id' : item_id , 'name' : class_obj .get (item_id , prop_name )}
53+ result = [{'id' : item_id , prop_name : class_obj .get (item_id , prop_name )}
5454 for item_id in class_obj .list ()
5555 if self .db .security .hasPermission ('View' , self .db .getuid (),
5656 class_name ,
@@ -71,6 +71,7 @@ def get_element(self, class_name, item_id, input):
7171 class_name , prop_name ,
7272 item_id )]
7373 result = dict (result )
74+ result ['id' ] = item_id
7475
7576 return result
7677
@@ -187,7 +188,15 @@ def dispatch(self, method, uri, input):
187188 except AttributeError :
188189 raise NotImplementedError ('Method is invalid' )
189190 finally :
190- output = json . JSONEncoder ().encode (output )
191+ output = RoundupJSONEncoder ().encode (output )
191192
192193 print "Length: %s - Content(50 char): %s" % (len (output ), output [:50 ])
193194 return output
195+
196+ class RoundupJSONEncoder (json .JSONEncoder ):
197+ def default (self , obj ):
198+ try :
199+ result = json .JSONEncoder .default (self , obj )
200+ except TypeError :
201+ result = str (obj )
202+ return result
0 commit comments