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