本文整理汇总了Python中app.user.models.User.get_or_404方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_or_404方法的具体用法?Python User.get_or_404怎么用?Python User.get_or_404使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.user.models.User
的用法示例。
在下文中一共展示了User.get_or_404方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: put
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_or_404 [as 别名]
def put(self, object_id):
user = user_model.get_or_404(object_id, message='User not found')
if g.user != user and not g.user.admin:
api.abort(403)
args = users_put.parse_args()
email = args['email']
password = args['password']
if email is not None and user.email != email:
if user_model.get_by_email(email) is not None:
api.abort(400, 'Email is already registered')
user.email = email
if password is not None:
user.set_password(password)
user.put()
return '', 200
示例2: delete
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_or_404 [as 别名]
def delete(self, object_id):
user = user_model.get_or_404(object_id, message='User not found')
if g.user != user and not g.user.admin:
api.abort(403)
user.key.delete()
return '', 204
示例3: get
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import get_or_404 [as 别名]
def get(self, object_id):
user = user_model.get_or_404(object_id, message='User not found')
if g.user is not None:
if g.user == user or g.user.admin:
return api.marshal(user, private_user)
return api.marshal(user, public_user)