def post_(self, user):
        answer = SurveyAnswer()
        answer.populateFromRequest(self.request.Params)
        answer.Put()

        summary = SurveyAnswerSummary.get_or_insert("%s" % answer.year, parent=answer.survey_question)

        if user:
            recordAnswer(summary.key, answer)

        self.jsonReply(answer.hashify())
        self.genericGetCollection(
            ndb.gql("SELECT __key__ FROM SurveyAnswer WHERE survey_submission = :1 ORDER BY position",
                    survey_submission))

    def post_unauthenticated_(self):
        self.post_(None)

    def post_(self, user):
        answer = SurveyAnswer()
        answer.populateFromRequest(self.request.Params)
        answer.Put()

        summary = SurveyAnswerSummary.get_or_insert("%s" % answer.year, parent=answer.survey_question)

        if user:
            recordAnswer(summary.key, answer)

        self.jsonReply(answer.hashify())

SurveyAnswer.collectionHandler(SurveyAnswerCollectionHandler)

class SurveyAnswerSummaryCollectionHandler (HardenedHandler):

    def get_(self, user):
        self.genericGetCollection(
            ndb.gql("SELECT __key__ FROM SurveyAnswerSummary WHERE survey_question = :1",
                    self.lookupKey(param='survey_question')))


SurveyAnswerSummary.collectionHandler(SurveyAnswerSummaryCollectionHandler)