suds-community / suds

Suds is a lightweight SOAP python client for consuming Web Services. A community fork of the jurko fork.
https://suds.readthedocs.io/
GNU Lesser General Public License v3.0
173 stars 55 forks source link

suds build error: missing attribute (multi_occurance) #74

Closed sharangdeo closed 2 years ago

sharangdeo commented 2 years ago

I encountered this in the traceback:

_*_/bingads/service_client.py", line 38, in process if type.multi_occurrence(): AttributeError: 'Element' object has no attribute 'multi_occurrence'

It concluded with:

An error occured while building a instance of (DynamicSearchAdsSetting).  As a result
        the object you requested could not be constructed.  It is recommended
        that you construct the type manually using a Suds object.
        Please open a ticket with a description of this error.
        Reason: 'Element' object has no attribute 'multi_occurrence'

Is this something that can be fixed? Or is it a flawed dependency on my end?

For reference, here is a quick glance at the process method where it breaks:

def process(self, data, type, history):
 29         """ process the specified type then process its children """
 30         if type in history:
 31             return
 32         if type.enum():
 33             return
 34         history.append(type)
 35         resolved = type.resolve()
 36         value = None
 37 
 38         if type.multi_occurrence():
 39             value = []
 40         else:
 41             if len(resolved) > 0:
 42                 if resolved.mixed():
 43                     value = SFactory.property(resolved.name)
 44                     md = value.__metadata__
 45                     md.sxtype = resolved
 46                 else:
 47                     value = SFactory.object(resolved.name)
 48                     md = value.__metadata__
 49                     md.sxtype = resolved
 50                     md.ordering = self.ordering(resolved)
 51 
 52         setattr(data, type.name, value)
 53         if value is not None:
 54             data = value
 55         if not isinstance(data, list):
 56             self.add_attributes(data, resolved)
 57             for child, ancestry in resolved.children():
 58                 if self.skip_child(child, ancestry):
 59                     continue
 60                 self.process(data, child, history[:])
phillbaker commented 2 years ago

Hello - that stack trace points to a BingAds subclasses of Suds code: https://github.com/BingAds/BingAds-Python-SDK/blob/e7b5a618e87a43d0a5e2c79d9aa4626e208797bd/bingads/service_client.py#L38-L40. This issue will have to be resolved in that code base, suds is just an upstream dependency.

There was discussion of some of these issues in https://github.com/suds-community/suds/issues/67. Suds ended up making that class more easily inherited/overridden, that may be a solution for them to investigate, see: https://github.com/suds-community/suds/commit/366f7f1616595b9e4163a3f90fc6e84ac0ae23f5

phillbaker commented 2 years ago

Closing as this issue is not specific to this repository.