本文整理汇总了Python中user.User.from_json方法的典型用法代码示例。如果您正苦于以下问题:Python User.from_json方法的具体用法?Python User.from_json怎么用?Python User.from_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user.User
的用法示例。
在下文中一共展示了User.from_json方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: auth_back
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import from_json [as 别名]
def auth_back():
code = req.args.get('code')
SessionCredStorage().put(oa2flow.step2_exchange(code))
# Grabbing and storing user identity
cred = SessionCredStorage().get()
path = "https://login.eveonline.com/oauth/verify"
http = httplib2.Http()
http = cred.authorize(http)
(header, content) = http.request("%s" % (path), "GET")
session['user'] = pickle.dumps(User.from_json(content))
# Back home
return redirect(url_for("index"))
示例2: update_user
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import from_json [as 别名]
def update_user(userid):
try:
user = User.from_json(json.loads(request.get_data()))
UsersTable.update(g.connection, userid, user)
return success(status.HTTP_200_OK)
except (ValidationError, ValueError):
return error(status.HTTP_400_BAD_REQUEST, "input validation failed")
except RequiredRecordNotFound:
return error(status.HTTP_404_NOT_FOUND, "user {0} not found".format(userid))
except RecordAlreadyExists:
return error(
status.HTTP_409_CONFLICT,
"update_failed: userid {0} is already taken".format(user.userid)
)
示例3: create_user
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import from_json [as 别名]
def create_user():
"""
create a user and add them to requested groups
any groups which don't exist will be created.
"""
try:
user = User.from_json(json.loads(request.get_data()))
UsersTable.save(g.connection, user)
GroupsTable.add_user_to_groups(g.connection, user.userid, user.groups)
return success(status.HTTP_200_OK)
except (ValidationError, ValueError):
return error(status.HTTP_400_BAD_REQUEST, "input validation failed")
except RecordAlreadyExists:
return error(status.HTTP_409_CONFLICT, "user {0} already exists".format(user.userid))