BingAds / BingAds-Python-SDK

Other
117 stars 162 forks source link

suds build error: missing attribute (multi_occurance) #201

Closed sharangdeo closed 2 years ago

sharangdeo commented 2 years ago

Encountered a suds.BuildError. Raised this elsewhere, but not sure if that was the right place for this to go.

The issue on suds repo

Thanks!

sharangdeo commented 2 years ago

Adding a bit of context about the error. 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[:])
qitia commented 2 years ago

Per the discussion https://github.com/suds-community/suds/issues/67, we will update suds to versoin to 1.1.0. This way we can override its Builder's skip_value method.

Please expect version 13.0.14 at end of June.