Kee Suds Module Cycle-dependent pits

Source: Internet
Author: User

The following is the core code of the SOA interface call

# !/usr/bin/python # Coding:utf-8  from Import Client
def soarequest (wsdl,fnname,data): = Client (WSDL). Service = getattr (soaservice,fnname) (data) return Soarep

The problem arises:

I call an interface, always error, see:

After the debug breakpoint is positioned to the Suds module, the open method of the import class in the sxbasic.py file

    defopen (Self, options):"""Open and import the refrenced schema.        @param options:an Options Dictionary. @type options:l{options.        Options} @return: the referenced schema. @rtype: L{schema}"""        ifself.opened:returnself.opened=True Log.debug ('%s, importing ns= "%s", location= "%s "', Self.id, Self.ns[1], self.location) result=self.locate ()ifResult isNone:ifSelf.location isNone:log.debug ('imported schema (%s) Not-found', self.ns[1])            Else:result =self.download (Options) Log.debug ('imported:\n%s', result)returnResult
Log Print when self.location is None, or execute download
And the interface I'm testing has this problem, a relies on b,b in dependency c,c in a, cyclic dependency
Everything's going to be a problem.

All right, then change it.
To define an array variable outside of class import resultlist = []
    defopen (Self, options):Globalresultlist# declaring global variables        ifself.opened:returnself.opened=True Log.debug ('%s, importing ns= "%s", location= "%s "', Self.id, Self.ns[1], self.location) result=self.locate ()ifResult isNone:ifSelf.location isNone:log.debug ('imported schema (%s) Not-found', self.ns[1])            Else:                ifSelf.locationinchResultList:log.debug ('already in Resultlist') #list中存在, which means that the download has completedElse:result =self.download (Options) resultlist.append (self.location) #下载完成后, add a record to the list Log.debug ('imported:\n%s', result)returnResult

That should be fine, run, or report the same mistake.

Continue debugging

Resultlist has been found to be empty, that is, the operation to add a record after the download operation is not executed

So I reversed the order.

Direct success

   defopen (Self, options):Globalresultlist        ifself.opened:returnself.opened=True Log.debug ('%s, importing ns= "%s", location= "%s "', Self.id, Self.ns[1], self.location) result=self.locate ()ifResult isNone:ifSelf.location isNone:log.debug ('imported schema (%s) Not-found', self.ns[1])            Else:                ifSelf.locationinchResultList:log.debug ('already in Resultlist')                Else: Resultlist.append (self.location) result=self.download (Options) Log.debug ('imported:\n%s', result)returnResult

Kee Suds Module Cycle-dependent pits

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.