[Fedora-suds-list] Does servicedefinition.py class ServiceDefinition method findport have a bad comparison?

Rod Montgomery monty at starfief.com
Tue Nov 3 21:18:58 UTC 2009


In file servicedefinition.py, the findport method of class ServiceDefinition reads as follows:

     def findport(self, port):
         """
         Find and return a port tuple for the specified port.
         Created and added when not found.
         @param port: A port.
         @type port: I{service.Port}
         @return: A port tuple.
         @rtype: (port, [method])
         """
         for p in self.ports:
             if p[0] == p: return p
         p = (port, [])
         self.ports.append(p)
         return p

Should not the comparison be  if p[0] == port  rather than  if p[0] == p  ?

I don't quite see how to trigger the failure. It would have to be a situation in which the same port had to be looked up a 
second time. The only invocation of the  findport  method is from the  addports  method immediately above it, and the only 
invocation of  addports  is from the  __init__  method for the class. I think that means it would take a second appearance of 
the same port in the WSDL to trigger a failure.

Maybe a situation in which some methods for a port are defined in one WSDL file, and others in a second WSDL file?




More information about the suds mailing list