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()
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()