本文整理汇总了Python中model.user.User.validate方法的典型用法代码示例。如果您正苦于以下问题:Python User.validate方法的具体用法?Python User.validate怎么用?Python User.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.user.User
的用法示例。
在下文中一共展示了User.validate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_validate_fails
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import validate [as 别名]
def test_validate_fails(self):
user = User(self.complete_data)
user.email = 'fake'
user.private_token = 'fake'
user.auth_token = 'fake'
user.salt = 'fake'
with assert_raises(ModelValidationError) as cm:
user.validate()
ok_('email' in cm.exception.messages.keys())
ok_('private_token' in cm.exception.messages.keys())
ok_('auth_token' in cm.exception.messages.keys())
ok_('salt' in cm.exception.messages.keys())
示例2: login
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import validate [as 别名]
def login() :
if session.get('is_admin') :
return redirect(url_for('.index'))
username = request.form.get('username')
password = request.form.get('password')
if not username or not password :
if not username :
username = ''
return render_template('admin/login.html', username=username)
## 验证用户是否合法
user = User.validate(username, password)
if user :
session['userid'] = user.id
session['username'] = user.name
session['is_admin'] = user.admin
redirectUrl = request.args.get('redirectUrl')
if not redirectUrl :
redirectUrl = '/'
return redirect(redirectUrl)
return render_template('admin/login.html', username=username)
示例3: test_validate_complete
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import validate [as 别名]
def test_validate_complete(self):
user = User(self.complete_data)
user.validate()
示例4: test_validate_minimum_data
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import validate [as 别名]
def test_validate_minimum_data(self):
user = User(self.minimum_data)
user.validate()