当前位置: 首页>>代码示例>>Python>>正文


Python User.from_json方法代码示例

本文整理汇总了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"))
开发者ID:gkrnours,项目名称:starroamer,代码行数:14,代码来源:server.py

示例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)
        )
开发者ID:Chandler,项目名称:planet_app,代码行数:16,代码来源:planet_app.py

示例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))
开发者ID:Chandler,项目名称:planet_app,代码行数:16,代码来源:planet_app.py


注:本文中的user.User.from_json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。