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


Python User.add_user方法代码示例

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


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

示例1: test_user

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_user [as 别名]
 def test_user(self):
     delete_db.delete_data_in_db()
     user = User()
     user.add_user()
     user.add_user()
     user.login()
     user.update_user()
     user.get_user()
     user.get_all_users()
     user.is_logged_in()
     user.delete_user()
开发者ID:headlins,项目名称:dose2014,代码行数:13,代码来源:test_service.py

示例2: register

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_user [as 别名]
def register():
    """ handles user registration """

    app.logger.debug('registering user')

    form = RegisterForm(request.form)
    if form.validate():
        app.logger.debug('The user name(%s) and password(%s) ', form.email.data, form.password.data)
        user = User(form.email.data, form.password.data)
        if user.add_user():
            login_user(user)
            flash('Thanks for registering')
        else:
            flash('User already registered.Try login')
    else:
        app.logger.debug('form error(%s)', form.errors)
        flash_errors(form)
    return redirect('/')
开发者ID:PradheepShrinivasan,项目名称:picourl,代码行数:20,代码来源:views.py

示例3: signup

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_user [as 别名]
def signup():
    errors = None
    if request.method == "POST":
        current_app.logger.debug(request.method + " Signup")
        
        form = SignupForm(request.form)

        if form.validate():
            current_app.logger.debug("login validation successful")
            
            email = form.email.data
            password = form.password.data            
            username = form.username.data
            
            users = User.get_users_by_email(email)

            if len(users) <= 0:
                user = User.add_user(username, email, password)           
                if login_user(user, True):
                    msg = u"Account created for " + username                    
                    current_app.logger.debug(msg)
                    helpers.get_flashed_messages() # to clean the flash cache
                    return redirect(url_for("index"))                    
                else:
                    errors = []
                    msg = u"Sorry, but you could not sign up."
                    current_app.logger.debug(msg)
                    errors.append(msg)
            else:
                errors = []
                msg = u"This email already registered. Please login or use another email."
                current_app.logger.debug(msg)
                errors.append(msg)
        elif form.errors:
            current_app.logger.debug("login validation failed")
            errors = []            
            for field, err in form.errors.items():
                for error in err:
                    errors.append(getattr(form, field).label.text + " : " + error)
    else:
        form = SignupForm()
    return render_template("signup.html", form = form, errors = errors)
开发者ID:go13,项目名称:Enigma53,代码行数:44,代码来源:auth_bp.py

示例4: create_user_and_login

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_user [as 别名]
 def create_user_and_login(self):
     user = User()
     user.add_user()
     user.login()
     return user
开发者ID:headlins,项目名称:dose2014,代码行数:7,代码来源:test_service.py


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