本文整理汇总了Python中models.Answer.gql方法的典型用法代码示例。如果您正苦于以下问题:Python Answer.gql方法的具体用法?Python Answer.gql怎么用?Python Answer.gql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Answer
的用法示例。
在下文中一共展示了Answer.gql方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_rev_set_raw
# 需要导入模块: from models import Answer [as 别名]
# 或者: from models.Answer import gql [as 别名]
def get_rev_set_raw(rev):
qs = []
#first object to be the description of the revision
lect_class = LectClass.get(rev.lect_class)
rev_desc = {
'lecturer':rev.user.name,
'institution':rev.user.institution,
'title':rev.title,
'class':lect_class.name,
'description':rev.description,
'created':rev.created.strftime("%B %d, %Y")
}
qs.append(rev_desc)
questions = Question.gql('WHERE revision = :1',rev).fetch(100) #how do we fetch all the Qs?
for q in questions:
answers = Answer.gql('WHERE question=:1',q)
ans = []
for a in answers:
ans.append(a.answer)
question = {
'question':q.question.replace("\n","").replace("\r",""),
'answers':ans
}
qs.append(question)
return qs
示例2: get_rev_set
# 需要导入模块: from models import Answer [as 别名]
# 或者: from models.Answer import gql [as 别名]
def get_rev_set(rev):
questions = Question.gql('WHERE revision = :1',rev).fetch(100) #how do we fetch all the Qs?
qs = []
for q in questions:
answers = Answer.gql('WHERE question=:1',q)
comments = QuestionComment.gql('WHERE question=:1',q)
comments_ = []
for c in comments:
c_ = {
'comment':c.comment,
'ckey':c.key().__str__(),
'user':QAUser.get(c.ukey)
}
comments_.append(c_)
question = {
'question':q,
'qkey':q.key().__str__(),
'answers':answers,
'comments':comments_,
'comment_count':comments.count()
}
qs.append(question)
return qs