本文整理匯總了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