本文整理汇总了Python中models.User.User.put方法的典型用法代码示例。如果您正苦于以下问题:Python User.put方法的具体用法?Python User.put怎么用?Python User.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.User.User
的用法示例。
在下文中一共展示了User.put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_user
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import put [as 别名]
def update_user(self, first_name, last_name, email):
user = db.GqlQuery('SELECT * FROM User WHERE uid = :1',
self.cid).get()
if not user:
new_user = User(uid=self.cid,
first_name=first_name,
last_name=last_name,
email=email,
validated=False)
new_user.put()
else:
setattr(user, "first_name", first_name)
setattr(user, "last_name", last_name)
setattr(user, "email", email)
user.put()
return("OK")
示例2: _get_user_profile
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import put [as 别名]
def _get_user_profile():
"""Returns User obj from datastore. Will create new one if non-existent."""
# Ensure user is authenticated with Google+
gplus_user = get_endpoints_current_user()
# Attempt to get User from datastore
user_id = gplus_user.email()
user_key = ndb.Key(User, user_id)
user = user_key.get()
# Create new User in datastore if it doesn't exist
if not user:
user = User(
key=user_key,
displayName=gplus_user.nickname(),
email=gplus_user.email()
)
user.put()
return user