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


Python Client.multiCall方法代碼示例

本文整理匯總了Python中suds.client.Client.multiCall方法的典型用法代碼示例。如果您正苦於以下問題:Python Client.multiCall方法的具體用法?Python Client.multiCall怎麽用?Python Client.multiCall使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在suds.client.Client的用法示例。


在下文中一共展示了Client.multiCall方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: API

# 需要導入模塊: from suds.client import Client [as 別名]
# 或者: from suds.client.Client import multiCall [as 別名]

#.........這裏部分代碼省略.........
        If you want to use the API as a normal class, then you have to manually
        end the session. A typical example is below::

            from magento.api import API

            api = API(url, username, password)
            api.connect()
            try:
                return api.call('customer.list', [])
            finally:
                api.client.endSession(api.session)

        :param url: URL to the magento instance.
                    By default the URL is treated as a base url
                    of the domain to which the api part of the URL
                    is added. If you want to specify the complete
                    URL, set the full_url flag as True.
        :param username: API username of the Web services user. Note
                    that this is NOT magento admin username
        :param password: API password of the Web services user.
        :param version: The version of magento the connection is being made to.
                        It is recommended to specify this as there could be
                        API specific changes in certain calls. Default value is
                        1.3.2.4
        :param full_url: If set to true, then the `url` is expected to
                    be a complete URL
        :param protocol: 'xmlrpc' and 'soap' are valid values
        :param transport: optional xmlrpclib.Transport subclass for
                    use in xmlrpc requests
        """
        assert protocol \
            in PROTOCOLS, "protocol must be %s" % ' OR '.join(PROTOCOLS)
        self.url = str(full_url and url or expand_url(url, protocol))
        self.username = username
        self.password = password
        self.protocol = protocol
        self.version = version
        self.transport = transport
        self.session = None
        self.client = None

    def connect(self):
        """
        Connects to the service
        but does not login. This could be used as a connection test
        """
        if self.protocol == 'xmlrpc':
            if self.transport:
                self.client = ServerProxy(
                    self.url, allow_none=True, transport=self.transport)
            else:
                self.client = ServerProxy(self.url, allow_none=True)
        else:
            self.client = Client(self.url)

    def __enter__(self):
        """
        Entry point for with statement
        Logs in and creates a session
        """
        if self.client is None:
            self.connect()
        if self.protocol == 'xmlrpc':
            self.session = self.client.login(
                self.username, self.password)
        else:
            self.session = self.client.service.login(
                self.username, self.password)
        return self

    def __exit__(self, type, value, traceback):
        """
        Exit point

        Closes session with magento
        """
        if self.protocol == 'xmlrpc':
            self.client.endSession(self.session)
        else:
            self.client.service.endSession(self.session)
        self.session = None

    def call(self, resource_path, arguments):
        """
        Proxy for SOAP call API
        """
        if self.protocol == 'xmlrpc':
            return self.client.call(self.session, resource_path, arguments)
        else:
            return self.client.service.call(
                self.session, resource_path, arguments)

    def multiCall(self, calls):
        """
        Proxy for multicalls
        """
        if self.protocol == 'xmlrpc':
            return self.client.multiCall(self.session, calls)
        else:
            return self.client.service.multiCall(self.session, calls)
開發者ID:gusreyes01,項目名稱:python-magento,代碼行數:104,代碼來源:api.py


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