本文整理匯總了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)