How to use multiple random strings in Python / Pyramid? -


so have definition saves user's profile. have 1 success message, rotate between multiple success , error messages the:
value = {'result': 'success', 'message': '...'}

how go this?

@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 nsa... far know"}     except exception, err:         print err         value = {'result': 'error', 'message': 'the internets clogged up, our monkeys checking out'} 

have list of success/error messages:

import random errors = ['dog ate it', 'flying monkeys stole it', 'rabbits attacked it'] value = {'result': 'error', 'message': random.choice(errors)} 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -