本文整理汇总了Python中models.Response.put方法的典型用法代码示例。如果您正苦于以下问题:Python Response.put方法的具体用法?Python Response.put怎么用?Python Response.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Response
的用法示例。
在下文中一共展示了Response.put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Response [as 别名]
# 或者: from models.Response import put [as 别名]
def post(self):
newUser = Responder(name = self.request.get('name'), email = self.request.get('email'), company = self.request.get('company'))
newUser.put()
set = ResponseSet(product = 'ADSync', responder = newUser)
set.put()
adQuestions = Question.gql('WHERE product = :1', 'ADSync')
htmlBody = '<h2>Response to ADSync Questionnaire</h2><p><i>Submitted by ' + newUser.name +', ' + newUser.email + '</i></p>'
for adQuestion in adQuestions:
responseText = self.request.get('response' + str(adQuestion.key().id()))
response = Response(text = responseText, question = adQuestion, responseSet = set)
response.put()
htmlBody += '<h3>' + adQuestion.text + '</h3>' + '<p>' + response.text + '</p>'
#send email notification
sender = '[email protected]'
recipients = ['[email protected]', '[email protected]', '[email protected]']
sub = newUser.name + ' from ' + newUser.company + ' responded to the ADSync Questionnaire'
plainBody = 'Get response here: http://yammerie.appspot.com/responsesets?id=' + str(set.key().id())
mail.send_mail(sender, recipients, sub, plainBody, html = htmlBody)
self.redirect('/adsuccess')
示例2: test_hooks
# 需要导入模块: from models import Response [as 别名]
# 或者: from models.Response import put [as 别名]
def test_hooks(self):
resp = Response(id='x', activity_json='{"foo": "bar"}')
self.assertRaises(AssertionError, resp.put)
pre_put = Response._pre_put_hook
del Response._pre_put_hook
resp.put()
Response._pre_put_hook = pre_put
got = resp.key.get()
self.assertEqual(['{"foo": "bar"}'], got.activities_json)
self.assertIsNone(got.activity_json)