本文整理汇总了Python中model.User.User.key方法的典型用法代码示例。如果您正苦于以下问题:Python User.key方法的具体用法?Python User.key怎么用?Python User.key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User.User
的用法示例。
在下文中一共展示了User.key方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import key [as 别名]
def post(self):
username = self.request.get("username")
password = self.request.get("password")
verify = self.request.get("verify")
email = self.request.get("email")
username_error = ""
password_error = ""
verify_error = ""
email_error = ""
users = db.GqlQuery("select * from User where name='%s'" % escape(username))
if users.count(1):
username_error = "User with such name already exists"
if not valid_username(username):
username_error = "That's not valid username"
if not valid_password(password):
password_error = "That's not valid password"
if password != verify:
verify_error = "Your passwords didn't match"
if email and not valid_email(email):
email_error = "That's not valid email"
if username_error or password_error or verify_error or email_error:
self.render_form(
username, password, verify, email, username_error, password_error, verify_error, email_error
)
else:
hash_salt = make_hash_salt(username, password)
user = User(name=username, email=email, hashpw=hash_salt[0], salt=hash_salt[1])
user.put()
cookie = "%s|%s" % (user.key().id(), user.hashpw)
self.response.headers.add_header("Set-Cookie", "ikariblog_user=%s; Path=/" % cookie)
self.redirect("/blog/welcome")