本文整理汇总了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)