当前位置: 首页>>代码示例>>Python>>正文


Python User.validate方法代码示例

本文整理汇总了Python中models.user.User.validate方法的典型用法代码示例。如果您正苦于以下问题:Python User.validate方法的具体用法?Python User.validate怎么用?Python User.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.user.User的用法示例。


在下文中一共展示了User.validate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_user_name_required

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import validate [as 别名]
def test_user_name_required(db_conn):
    """
    Ensure a name is required.
    """
    user = User()
    errors = user.validate()
    assert len(errors) > 0
    assert "name" in [e["name"] for e in errors]
开发者ID:Folashade,项目名称:sagefy,代码行数:10,代码来源:test_models_user.py

示例2: test_user_password_minlength

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import validate [as 别名]
def test_user_password_minlength(db_conn):
    """
    Ensure an password is long enough.
    """
    user = User({"password": "abcd"})
    errors = user.validate()
    assert "password" in [e["name"] for e in errors]
    assert "Must have minimum length of 8." in [e["message"] for e in errors]
开发者ID:Folashade,项目名称:sagefy,代码行数:10,代码来源:test_models_user.py

示例3: test_user_email_format

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import validate [as 别名]
def test_user_email_format(db_conn):
    """
    Ensure an email is formatted.
    """
    user = User({"email": "other"})
    errors = user.validate()
    assert "email" in [e["name"] for e in errors]
    assert "Must be an email." in [e["message"] for e in errors]
开发者ID:Folashade,项目名称:sagefy,代码行数:10,代码来源:test_models_user.py

示例4: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import validate [as 别名]
    def post(self):
        try:
            email = self.get_argument("email")
            try:
                user = User.objects.get(email=email)
            except User.DoesNotExist:
                raise ValidationError('dup_email')

            user = User()
            user.email = email
            user.validate()

        except ValidationError as e:
            self.error()
            self.ERRORS[str(e)] = True
            self.render_signup()

        else:
            self.render_password(email=email)
开发者ID:JFK,项目名称:python-tornado-site-template,代码行数:21,代码来源:__init__.py

示例5: signup

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import validate [as 别名]
def signup():
    next_url = request.args.get('next') or request.form.get('next') or ''

    if not g.user.is_anonymous():
        return redirect(next_url or url_for('home'))

    user = User()
    if request.method == 'POST':
        username = request.form.get('username') or ''
        password = request.form.get('password') or ''
        #discoverable = request.form.get('discoverable_by_email', True, bool) == True
        user = User(username=username, password=password)
        if user.validate():
            user.save_new_user()
            login_user(user, True)
            return redirect(next_url or url_for('home'))

    return render(page='signup', title=gettext('Sign up'), section='signup', user=user, next_url=next_url)
开发者ID:smaili,项目名称:ripto,代码行数:20,代码来源:app.py

示例6: login

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import validate [as 别名]
def login():
    '''
    username: string 
    passwd: 32bit md5 code
    '''
    try:
        username = request.form['username']
        passwd = request.form['passwd']
    except KeyError:
        return error(400, u'参数错误')
    if len(passwd) == 0 or len(username) == 0:
        return error(10005, u'用户名密码不能为空')
    user = User.validate(username, passwd)
    if not user:
        return error(10006, u'用户名或密码错误')
    login_user(user)
    # login_user(user, remember = remember_me)
    return user.dict()
开发者ID:DlutCS,项目名称:nserver_py,代码行数:20,代码来源:admin.py


注:本文中的models.user.User.validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。