本文整理匯總了Python中openid.message.NamespaceMap.iterNamespaceURIs方法的典型用法代碼示例。如果您正苦於以下問題:Python NamespaceMap.iterNamespaceURIs方法的具體用法?Python NamespaceMap.iterNamespaceURIs怎麽用?Python NamespaceMap.iterNamespaceURIs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類openid.message.NamespaceMap
的用法示例。
在下文中一共展示了NamespaceMap.iterNamespaceURIs方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_iteration
# 需要導入模塊: from openid.message import NamespaceMap [as 別名]
# 或者: from openid.message.NamespaceMap import iterNamespaceURIs [as 別名]
def test_iteration(self):
nsm = NamespaceMap()
uripat = 'http://example.com/foo%r'
nsm.add(uripat % 0)
for n in range(1, 23):
self.assertIn(uripat % (n - 1), nsm)
self.assertTrue(nsm.isDefined(uripat % (n - 1)))
nsm.add(uripat % n)
for (uri, alias) in nsm.items():
self.assertEqual(uri[22:], alias[3:])
for (uri, alias) in nsm.iteritems():
self.assertEqual(uri[22:], alias[3:])
self.assertEqual(len(tuple(nsm.iterAliases())), 23)
self.assertEqual(len(tuple(nsm.iterNamespaceURIs())), 23)
示例2: parseExtensionArgs
# 需要導入模塊: from openid.message import NamespaceMap [as 別名]
# 或者: from openid.message.NamespaceMap import iterNamespaceURIs [as 別名]
def parseExtensionArgs(self, ax_args):
"""Given attribute exchange arguments, populate this FetchRequest.
@param ax_args: Attribute Exchange arguments from the request.
As returned from L{Message.getArgs<openid.message.Message.getArgs>}.
@type ax_args: dict
@raises KeyError: if the message is not consistent in its use
of namespace aliases.
@raises NotAXMessage: If ax_args does not include an Attribute Exchange
mode.
@raises AXError: If the data to be parsed does not follow the
attribute exchange specification. At least when
'if_available' or 'required' is not specified for a
particular attribute type.
"""
# Raises an exception if the mode is not the expected value
self._checkMode(ax_args)
aliases = NamespaceMap()
for key, value in six.iteritems(ax_args):
if key.startswith('type.'):
alias = key[5:]
type_uri = value
aliases.addAlias(type_uri, alias)
count_key = 'count.' + alias
count_s = ax_args.get(count_key)
if count_s:
try:
count = int(count_s)
if count <= 0:
raise AXError("Count %r must be greater than zero, got %r" % (count_key, count_s,))
except ValueError:
if count_s != UNLIMITED_VALUES:
raise AXError("Invalid count value for %r: %r" % (count_key, count_s,))
count = count_s
else:
count = 1
self.add(AttrInfo(type_uri, alias=alias, count=count))
required = toTypeURIs(aliases, ax_args.get('required'))
for type_uri in required:
self.requested_attributes[type_uri].required = True
if_available = toTypeURIs(aliases, ax_args.get('if_available'))
all_type_uris = required + if_available
for type_uri in aliases.iterNamespaceURIs():
if type_uri not in all_type_uris:
raise AXError(
'Type URI %r was in the request but not '
'present in "required" or "if_available"' % (type_uri,))
self.update_url = ax_args.get('update_url')