本文整理汇总了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()