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="connections, successfully deletd id: " + str(m.id), data=str(m.id), format="json") except Exception as e: self.error(message="connections, destroy id: " + str(e))
def create(self): try: data_json = self.request.body m=Model() m.init_from_json(data_json, simple_conversion=True) m.upsert() self.success(message="connections, successfully created " + str(m.id), data=m, format="json") except Exception as e: self.error(message="connections, error updating " + str(m.id) + "msg: " + str(e), data=m, format="json")