本文整理汇总了Python中app.user.models.User.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_by_id方法的具体用法?Python User.get_by_id怎么用?Python User.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.user.models.User
的用法示例。
在下文中一共展示了User.get_by_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_by_id
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_id [as 别名]
def test_get_by_id(self):
"""Get user by ID."""
user = User('foo', '[email protected]')
user.save()
retrieved = User.get_by_id(user.id)
assert retrieved == user
示例2: current_user
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_id [as 别名]
def current_user():
args = token_parser.parse_args()
token = args['X-Session-Token']
valid, data = User.verify_session_token(token)
g.user = None
if valid:
if not data.get('password_reset'):
g.user = User.get_by_id(data.get('user_id'))
示例3: post
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_id [as 别名]
def post(self):
args = password_confirm_post.parse_args()
token = args['reset_token']
password = args['password']
valid, data = user_model.verify_session_token(token)
if not valid or not data.get('password_reset'):
api.abort(400, 'Reset token is invalid')
user = user_model.get_by_id(data.get('user_id'))
user.set_password(password)
user.put()
return '', 200
示例4: load_user
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_id [as 别名]
def load_user(id):
return User.get_by_id(int(id))
示例5: load_user
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_by_id [as 别名]
def load_user(user_id):
"""Load user by ID."""
return User.get_by_id(int(user_id))