def GetTaskById(self, request): if request.id is None: raise endpoints.BadRequestException('id field is required.') task = Task.get_by_id(request.id) if task is None or task.user != self.GetUserId(): raise endpoints.NotFoundException('No task entity with the id "%s" exists.' % request.id) return task.ConvertToResponse()
def UpdateTask(self, request): result = TaskResponse() task = Task.get_by_id(request.id) if task != None and task.user == self.GetUserId(): if task.last_updated <= request.client_copy_timestamp: task.MergeFromMessage(request) task.put() result = task.ConvertToResponse() else: raise endpoints.NotFoundException("The item was updated on the outside") else: raise endpoints.NotFoundException('No task entity with the id "%s" exists.' % request.id) return result