本文整理汇总了Python中openid.extensions.sreg.SRegResponse.fromSuccessResponse方法的典型用法代码示例。如果您正苦于以下问题:Python SRegResponse.fromSuccessResponse方法的具体用法?Python SRegResponse.fromSuccessResponse怎么用?Python SRegResponse.fromSuccessResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openid.extensions.sreg.SRegResponse
的用法示例。
在下文中一共展示了SRegResponse.fromSuccessResponse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_value_from_response
# 需要导入模块: from openid.extensions.sreg import SRegResponse [as 别名]
# 或者: from openid.extensions.sreg.SRegResponse import fromSuccessResponse [as 别名]
def get_value_from_response(response, sreg_names=None, ax_names=None):
value = None
if sreg_names:
sreg = SRegResponse.fromSuccessResponse(response)
if sreg:
for name in sreg_names:
value = sreg.get(name)
if value:
break
if not value and ax_names:
ax = FetchResponse.fromSuccessResponse(response)
if ax:
for name in ax_names:
try:
values = ax.get(name)
if values:
value = values[0]
except KeyError:
pass
if value:
break
return value
示例2: sreg
# 需要导入模块: from openid.extensions.sreg import SRegResponse [as 别名]
# 或者: from openid.extensions.sreg.SRegResponse import fromSuccessResponse [as 别名]
def sreg(self):
"""
Try to get OpenID Simple Registation
http://openid.net/specs/openid-simple-registration-extension-1_0.html
"""
if self.resp:
resp = self.resp
sreg_resp = SRegResponse.fromSuccessResponse(resp)
return sreg_resp.data if sreg_resp else None
else:
return None
示例3: __init__
# 需要导入模块: from openid.extensions.sreg import SRegResponse [as 别名]
# 或者: from openid.extensions.sreg.SRegResponse import fromSuccessResponse [as 别名]
def __init__(self, resp, extensions):
sreg_resp = SRegResponse.fromSuccessResponse(resp)
self.sreg = sreg_resp and sreg_resp.data or {}
self.ax_resp = ax.FetchResponse.fromSuccessResponse(resp) or {}
# Process the OpenID response with the OpenIDResponse class provided
self.ext = {}
for extension in extensions:
ext_name = getattr(extension, 'ns_alias', extension.__name__)
self.ext[ext_name] = \
extension.fromSuccessResponse(resp)
示例4: get_email_from_response
# 需要导入模块: from openid.extensions.sreg import SRegResponse [as 别名]
# 或者: from openid.extensions.sreg.SRegResponse import fromSuccessResponse [as 别名]
def get_email_from_response(response):
email = None
sreg = SRegResponse.fromSuccessResponse(response)
if sreg:
email = valid_email_or_none(sreg.get(SRegField.EMAIL))
if not email:
ax = FetchResponse.fromSuccessResponse(response)
if ax:
try:
values = ax.get(AXAttribute.CONTACT_EMAIL)
if values:
email = valid_email_or_none(values[0])
except KeyError:
pass
return email