本文整理匯總了Python中constants.Constants.error_with_message_and_status方法的典型用法代碼示例。如果您正苦於以下問題:Python Constants.error_with_message_and_status方法的具體用法?Python Constants.error_with_message_and_status怎麽用?Python Constants.error_with_message_and_status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類constants.Constants
的用法示例。
在下文中一共展示了Constants.error_with_message_and_status方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: post
# 需要導入模塊: from constants import Constants [as 別名]
# 或者: from constants.Constants import error_with_message_and_status [as 別名]
def post(self):
parser = reqparse.RequestParser()
parser.add_argument('facebookID', type=str, help='Facebook ID', location='form')
parser.add_argument('email', type=str, help='User email', location='form', required=True)
parser.add_argument('firstName', type=str, help='First Name', location='form', required=True)
parser.add_argument('lastName', type=str, help='Last Name', location='form', required=True)
parser.add_argument('password', type=str, help='Password', location='form', required=True)
args = parser.parse_args()
person_model = PersonModel()
person_model.email = args['email']
items = PersonModel.query.filter_by(email=person_model.email).all()
if len(items) > 0:
return Constants.error_with_message_and_status('user_is_already_exist', 401)
parameter = 'password'
if not parameter in args:
return Constants.error_missed_parameter(parameter)
person_model.first_name = args['firstName']
person_model.last_name = args['lastName']
person_model.facebook_id = args['facebookID']
# Encrypt user password
password = request.form['password']
encr_password = passlib.encrypt(password, salt_length=100)
person_model.password = encr_password
# Generate user token with expiration date
person_model.token = TokenSerializer.generate_auth_token(person_model.person_id)
# Add person to the model
db.session.add(person_model)
db.session.commit()
return person_model.to_dict()