本文整理汇总了Python中model.User.User.put方法的典型用法代码示例。如果您正苦于以下问题:Python User.put方法的具体用法?Python User.put怎么用?Python User.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User.User
的用法示例。
在下文中一共展示了User.put方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import put [as 别名]
def get(self):
user = users.get_current_user()
#checks to see if we have a user signed in
if user:
userProfile = User.getByEmail(user.email())
#if user profile is empty create one
if not userProfile:
userProfile = User()
userProfile.email = user.email()
userProfile.nickname = 'Anonymous'
userProfile.score = 0
userProfile.played = 0
userProfile.put()
template_values = {
'user': userProfile
}
template = jinja_environment.get_template('profile.html')
self.response.out.write(template.render(template_values))
#if not is ask them to sign in
else:
template_values = {
'signinurl' : users.create_login_url("/")
}
template = jinja_environment.get_template('signin.html')
self.response.out.write(template.render(template_values))
示例2: GetUserId
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import put [as 别名]
def GetUserId(self):
if endpoints.get_current_user() == None:
raise endpoints.UnauthorizedException("Must log in")
user = User.query(User.username == endpoints.get_current_user().email()).get()
if user == None:
user = User(username = endpoints.get_current_user().email())
user.put()
return user.key
示例3: post
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.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")
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")
示例4: post
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.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')
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()
self.set_cookie(user)
self.redirect("/wiki/")
示例5: post
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import put [as 别名]
def post(self):
success = False
template_params={}
username=self.request.get('username')
password=self.request.get('password')
android=self.request.get('android')
use = User.all().filter('username',username)
if use.count() == 0:
#no collisions
nameTaken = False
if (password is not None) and (password != ""):
#valid password
badPass = False
#create user account
usernew = User(username=username,password=password)
usernew.put()
success=True
template_params={'success':success}
else:
#invalid password
badPass = True
template_params={'success':success,'badPass':badPass}
if android is not None and (android)==1:
if(badPass):
self.response.write("FAIL-BADPASS")
else:
self.response.write("OK")
else:
render_template(self,'createUser.html',template_params)
else:
if android is not None and (android)==1:
self.response.write("FAIL-BADNAME")
else:
#username taken
nameTaken = True
template_params={'success':success,'nameTaken':nameTaken}
render_template(self,'createUser.html',template_params)