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


Python AstakosClient.get_user_info方法代码示例

本文整理汇总了Python中astakosclient.AstakosClient.get_user_info方法的典型用法代码示例。如果您正苦于以下问题:Python AstakosClient.get_user_info方法的具体用法?Python AstakosClient.get_user_info怎么用?Python AstakosClient.get_user_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在astakosclient.AstakosClient的用法示例。


在下文中一共展示了AstakosClient.get_user_info方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: wrapper

# 需要导入模块: from astakosclient import AstakosClient [as 别名]
# 或者: from astakosclient.AstakosClient import get_user_info [as 别名]
        def wrapper(request, *args, **kwargs):
            try:
                # Get the requested serialization format
                serialization = get_serialization(
                    request, format_allowed, serializations[0])

                # If guessed serialization is not supported, fallback to
                # the default serialization or return an API error in case
                # strict serialization flag is set.
                if not serialization in serializations:
                    if strict_serlization:
                        raise faults.BadRequest(("%s serialization not "
                                                "supported") % serialization)
                    serialization = serializations[0]
                request.serialization = serialization

                # Check HTTP method
                if http_method and request.method != http_method:
                    raise faults.BadRequest("Method not allowed")

                # Get authentication token
                request.x_auth_token = None
                if token_required or user_required:
                    token = get_token(request)
                    if not token:
                        msg = "Access denied. No authentication token"
                        raise faults.Unauthorized(msg)
                    request.x_auth_token = token

                # Authenticate
                if user_required:
                    assert(token_required), "Can not get user without token"
                    astakos = astakos_url or settings.ASTAKOS_BASE_URL
                    astakos = AstakosClient(astakos,
                                            use_pool=True,
                                            retry=2,
                                            logger=logger)
                    user_info = astakos.get_user_info(token)
                    request.user_uniq = user_info["uuid"]
                    request.user = user_info

                # Get the response object
                response = func(request, *args, **kwargs)

                # Fill in response variables
                update_response_headers(request, response)
                return response
            except faults.Fault, fault:
                if fault.code >= 500:
                    logger.exception("API ERROR")
                return render_fault(request, fault)
开发者ID:mpastyl,项目名称:websocket-console,代码行数:53,代码来源:__init__.py


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