def post_(self, user): question = SurveyQuestion() question.populateFromRequest(self.request.Params) question.question_id = get_next_id() question.Put() logging.info("stored %s" % question) self.jsonReply(question.hashify())
Survey.collectionHandler(SurveyCollectionHandler) class SurveyQuestionHandler (HardenedHandler): def get_(self, user, key): self.genericIndividualGet(user, key) def post_(self, user, key): self.genericIndividualPost(user, key) def delete_(self, user, key): entity = self.lookupKey(urlsafe=key) entity.delete() SurveyQuestion.individualHandler(SurveyQuestionHandler) class SurveyQuestionCollectionHandler (HardenedHandler): def get_(self, user): survey = self.lookupKey(param='survey') self.genericGetCollection( ndb.gql("SELECT __key__ FROM SurveyQuestion WHERE survey = :1 ORDER BY position", survey)) def post_(self, user): question = SurveyQuestion() question.populateFromRequest(self.request.Params) question.question_id = get_next_id() question.Put() logging.info("stored %s" % question) self.jsonReply(question.hashify())