本文整理汇总了Python中DoctorSpring.models.User.get_by_name方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_by_name方法的具体用法?Python User.get_by_name怎么用?Python User.get_by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoctorSpring.models.User
的用法示例。
在下文中一共展示了User.get_by_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validate
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import get_by_name [as 别名]
def validate(self):
try:
if self.email is None or "@" not in self.email:
failure = ResultStatus(FAILURE.status, "邮箱地址格式不正确")
return failure
else:
user = User.get_by_name(self.email)
if user is not None:
failure = ResultStatus(FAILURE.status, "邮箱地址已注册")
return failure
if self.username is None:
failure = ResultStatus(FAILURE.status, "用户名为空")
return failure
if self.password is None:
failure = ResultStatus(FAILURE.status, "密码为空")
return failure
if self.real_name is None:
failure = ResultStatus(FAILURE.status, "真实姓名为空")
return failure
if self.identity_phone is None:
failure = ResultStatus(FAILURE.status, "注册号码为空")
return failure
if self.cellphone is None:
failure = ResultStatus(FAILURE.status, "手机号码格式不对")
return failure
else:
user = User.get_by_name(self.cellphone)
if user is not None:
failure = ResultStatus(FAILURE.status, "手机号码已注册")
return failure
except Exception, e:
return FAILURE
示例2: login
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import get_by_name [as 别名]
def login():
form = LoginForm(request.form)
formResult = form.validate()
if formResult.status == rs.SUCCESS.status:
# session['remember_me'] = form.remember_me.data
# login and validate the user...
user = User.get_by_name(form.username)
if user is not None and user.check_password(form.password):
login_session(user)
formResult.msg = request.host_url + "homepage"
else:
formResult = rs.LOGIN_CHECK_FARLURE
return jsonify(formResult.__dict__)
示例3: validate
# 需要导入模块: from DoctorSpring.models import User [as 别名]
# 或者: from DoctorSpring.models.User import get_by_name [as 别名]
def validate(self):
try:
if self.nickname is None:
failure = ResultStatus(FAILURE.status, "昵称为空")
return failure
if self.password is None:
failure = ResultStatus(FAILURE.status, "密码为空")
return failure
if self.name is None:
failure = ResultStatus(FAILURE.status, "用户名为空")
return failure
else:
user = User.get_by_name(self.name)
if user is not None:
failure = ResultStatus(FAILURE.status, "该用户已存在")
return failure
except Exception, e:
return FAILURE