當前位置: 首頁>>代碼示例>>Python>>正文


Python NamespaceMap.getAlias方法代碼示例

本文整理匯總了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)
開發者ID:ziima,項目名稱:python-openid,代碼行數:9,代碼來源:test_message.py

示例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
開發者ID:arhibot,項目名稱:python-openid,代碼行數:69,代碼來源:ax.py


注:本文中的openid.message.NamespaceMap.getAlias方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。