本文整理汇总了Python中User.put方法的典型用法代码示例。如果您正苦于以下问题:Python User.put方法的具体用法?Python User.put怎么用?Python User.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: import User [as 别名]
# 或者: from User import put [as 别名]
def post(self):
username = self.request.get("username")
password = self.request.get("password")
verify = self.request.get("verify")
email = self.request.get("email")
has_error = False
params = dict(username = username, email=email)
if not valid_username(username):
params['error_username'] = "That's not a valid username."
has_error = True
if not valid_password(password):
params['error_password'] = "That's not a valid password."
has_error = True
if not (password == verify):
has_error = True
params['error_verify'] = "Your passwords didn't match."
if email:
if not valid_email(email):
params['error_email'] = "That's not a valid email."
has_error = True
if has_error:
self.render('signup-form.html', **params)
else:
users = getByUsername(username)
if users.count() != 0:
params['error_user'] = "That user already exists"
self.render('signup-form.html', **params)
else:
hash_password = pw_hash(password)
u = User(username=username,password=hash_password,email=email)
u.put()
self.response.headers.add_header('Set-Cookie', 'user_id=%s; Path=/'%str(username))
self.redirect('/')
示例2: add_user
# 需要导入模块: import User [as 别名]
# 或者: from User import put [as 别名]
def add_user(username, password_hash, request):
set_cookie(username, request)
# add to db
user = User(username = username, password_hash = password_hash)
user.put()