def post(self): # create new list, return id new_list = TodoList() new_list.task_count = 0 new_list.remote_addr = self.request.remote_addr new_list.referer = self.request.headers.get('Referer') new_list.put() self.json({'list': new_list.to_dict()})
def post(self, account_id): self.response.headers['Content-Type'] = 'application/json' try: account = Account.get_by_id(int(account_id)) todo_list_data = json.loads(self.request.body) todo_list = TodoList(title=todo_list_data.get('title'), status=todo_list_data.get('status'), account=account.key, parent=account.key) todo_list.put() result = {'id': todo_list.key.id()} self.response.out.write(json.dumps(result)) except Exception as e: result = {'error': 'Unexpected error has occurred', 'message': e.message} self.response.set_status(500, json.dumps(result)) self.response.out.write(json.dumps(result))