def edit(self, id=None): m=Model() try: print(" .. GET Edit Data (ID): " + id) res = m.find_by_id(id) self.success(message="todo, edit id: " + str(id), data=res) except Exception as e: self.error(message="todo, edit id: " + str(id) + "msg: " + str(e) , data=None)
def destroy(self, id=None): try: data_json = self.request.body print(" .. DELETE Data: ID:" + str(data_json)) m=Model() m.init_from_json(data_json) res = m.find_by_id(m.id) res.delete() self.success(message="todo, destroy id: " + str(m.id)) except Exception as e: self.error(message="todo, destroy id: " + str(e))
def update(self, id=None): data_json = self.request.body m=Model() res = m.find_by_id(id) res.init_from_json(data_json, simple_conversion=True) try: #res.tags= res.tags.split(",") res.upsert() self.success(message="todo, successfully updated " + str(res.id), data=res, format="json") except Exception as e: self.error(message="todo, error updating: " + str(m.id) + "msg: " + str(e), data=data_json, format="json")
def show(self, id=None): m=Model() res=m.find_by_id(id) self.success(message="todo show", data=res)