所以我有这个定义,它基本上只是保存用户的个人资料。目前我有 1 条成功消息,我想在多个成功和错误消息之间轮换:
value = {'result': 'success', 'message': '...'}
你会怎么做?
@view_config(route_name="profile", request_method='POST')
def save_profile(self):
try:
json = self.request.json_body
first_name = str(json['firstName'])
last_name = str(json['lastName'])
organization = str(json['organization'])
title = str(json['title'])
phones = (json['phones'])
emails = (json['emails'])
self.profiles.update(firstName=first_name, lastName=last_name, organization=organization, title=title, emails=emails, phones=phones)
value = {'result': 'success', 'message': "Saved! Worry not, nothing sent to the NSA... as far as we know"}
except Exception, err:
print err
value = {'result': 'error', 'message': 'The internets are clogged up, our monkeys are checking it out'}