コード例 #1
0
 def get(self, id=None):
     dao = ListingDAO(self.db)
     if not id:
         dict_result = yield (dao.get_list())
     else:
         dict_result = yield (dao.get(id))
     self.write(json.dumps(dict_result))
     self.finish()
コード例 #2
0
 def put(self, id=None):
     if not hasattr(self, 'json_args'):
         self.write('invalid request')
         self.finish()
     else:
         dao = ListingDAO(self.db)
         if id:
             result = yield (dao.update(id, data=self.json_args))
             dict_result = yield (dao.get(id))
             self.write(json.dumps(dict_result))
         else:
             self.write('invalid listing')
         self.finish()