本文整理汇总了Python中openid.message.NamespaceMap.getAlias方法的典型用法代码示例。如果您正苦于以下问题:Python NamespaceMap.getAlias方法的具体用法?Python NamespaceMap.getAlias怎么用?Python NamespaceMap.getAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openid.message.NamespaceMap
的用法示例。
在下文中一共展示了NamespaceMap.getAlias方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_onealias
# 需要导入模块: from openid.message import NamespaceMap [as 别名]
# 或者: from openid.message.NamespaceMap import getAlias [as 别名]
def test_onealias(self):
nsm = NamespaceMap()
uri = 'http://example.com/foo'
alias = "foo"
nsm.addAlias(uri, alias)
self.assertEqual(nsm.getNamespaceURI(alias), uri)
self.assertEqual(nsm.getAlias(uri), alias)
示例2: getExtensionArgs
# 需要导入模块: from openid.message import NamespaceMap [as 别名]
# 或者: from openid.message.NamespaceMap import getAlias [as 别名]
def getExtensionArgs(self):
"""Serialize this object into arguments in the attribute
exchange namespace
@returns: The dictionary of unqualified attribute exchange
arguments that represent this fetch_response.
@rtype: {unicode;unicode}
"""
aliases = NamespaceMap()
zero_value_types = []
if self.request is not None:
# Validate the data in the context of the request (the
# same attributes should be present in each, and the
# counts in the response must be no more than the counts
# in the request)
for type_uri in self.data:
if type_uri not in self.request:
raise KeyError(
'Response attribute not present in request: %r'
% (type_uri,))
for attr_info in self.request.iterAttrs():
# Copy the aliases from the request so that reading
# the response in light of the request is easier
if attr_info.alias is None:
aliases.add(attr_info.type_uri)
else:
aliases.addAlias(attr_info.type_uri, attr_info.alias)
try:
values = self.data[attr_info.type_uri]
except KeyError:
values = []
zero_value_types.append(attr_info)
if (attr_info.count != UNLIMITED_VALUES) and \
(attr_info.count < len(values)):
raise AXError(
'More than the number of requested values were '
'specified for %r' % (attr_info.type_uri,))
kv_args = self._getExtensionKVArgs(aliases)
# Add the KV args into the response with the args that are
# unique to the fetch_response
ax_args = self._newArgs()
# For each requested attribute, put its type/alias and count
# into the response even if no data were returned.
for attr_info in zero_value_types:
alias = aliases.getAlias(attr_info.type_uri)
kv_args['type.' + alias] = attr_info.type_uri
kv_args['count.' + alias] = '0'
update_url = ((self.request and self.request.update_url)
or self.update_url)
if update_url:
ax_args['update_url'] = update_url
ax_args.update(kv_args)
return ax_args