本文整理汇总了Python中User.get方法的典型用法代码示例。如果您正苦于以下问题:Python User.get方法的具体用法?Python User.get怎么用?Python User.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: admin_users_edit_post
# 需要导入模块: import User [as 别名]
# 或者: from User import get [as 别名]
def admin_users_edit_post():
payload = get_payload(request)
user_id = payload.get('user_id')
if user_id:
user = User.get(user_id)
return_value = success('All profile values have been updated.')
else:
user = User()
user.insert()
return_value = success('User created.')
if not payload.get('password'):
return jsonify(failure('You must set a password for new users'))
if not payload.get('email'):
return jsonify(failure('You must set an email for new users'))
if not payload.get('name'):
return jsonify(failure('You must set a name for new users'))
for key in payload:
if key == 'password':
user.set_password(payload[key])
elif key != 'user_id':
setattr(user, key, payload[key])
g.user.insert()
safe_commit()
return jsonify(return_value)
示例2: adduser
# 需要导入模块: import User [as 别名]
# 或者: from User import get [as 别名]
def adduser(self, userkey, uname):
"""Add a user to the datastore."""
#Check for a user with that name
if User.get(uname) is not None:
raise RuntimeError("Username in use")
if User.gql("WHERE googleacct = :1", users.get_current_user()).count() > 0:
raise RuntimeError("Account in use")
User.(key_name=uname, userkey=userkey, uname=uname).put()
示例3: retrieve_user
# 需要导入模块: import User [as 别名]
# 或者: from User import get [as 别名]
def retrieve_user():
return_value = success('The user was retrieved.')
payload = get_payload(request)
user = User.get(payload.get('id'))
if not user:
return_value = failure('That user does not exist.')
else:
return_value['user'] = user.to_dict(camel_case=True)
return_value['user'].pop('password')
return_value['user'].pop('openid')
return jsonify(return_value)
示例4: update_user
# 需要导入模块: import User [as 别名]
# 或者: from User import get [as 别名]
def update_user():
return_value = success('The user was updated.')
payload = get_payload(request)
user = User.get(payload.get('id'))
if not user:
return_value = failure('That user does not exist.')
else:
if payload.get('password'):
user.set_password(payload.get('password'))
if payload.get('email'):
user.email = payload.get('email')
if payload.get('name'):
user.name = payload.get('name')
safe_commit()
return_value['user'] = user.to_dict(camel_case=True)
return jsonify(return_value)
示例5: admin_users_edit
# 需要导入模块: import User [as 别名]
# 或者: from User import get [as 别名]
def admin_users_edit(user_id=''):
user = User.get(user_id)
return render_template('user.html', user=user)