kartagis / pysimplesoap

Automatically exported from code.google.com/p/pysimplesoap
0 stars 0 forks source link

AttributeError: 'Struct' object has no attribute '_Struct__keys' #158

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
client = 
SoapClient(wsdl="https://webservices.netsuite.com/wsdl/v2014_1_0/netsuite.wsdl",
trace=True)

This produces error AttributeError: 'Struct' object has no attribute 
'_Struct__keys' before it even finishes parsing the WSDL properly.

I've included the full stack trace at the very bottom.  In this case my code is 
basic and I'm just trying to initialize things at this point, since I'm still 
learning the NetSuite API.

I was able to work around the issue by adding the following check into the 
__setitem__ function.  At which point it does finally parse the WSDL properly.

    def __setitem__(self, key, value):
+        if not hasattr(self, '__keys'):
+            self.__keys = []
        if key not in self.__keys:
            self.__keys.append(key)
        dict.__setitem__(self, key, value)

Traceback (most recent call last):
  File "NetSuiteClient_pysimplesoap.py", line 3, in <module>
    client = SoapClient(wsdl="https://webservices.netsuite.com/wsdl/v2014_1_0/netsuite.wsdl",trace=True)
  File "/usr/lib/python2.7/site-packages/PySimpleSOAP-1.16-py2.7.egg/pysimplesoap/client.py", line 172, in __init__
    self.services = wsdl and self.wsdl_parse(wsdl, cache=cache)
  File "/usr/lib/python2.7/site-packages/PySimpleSOAP-1.16-py2.7.egg/pysimplesoap/client.py", line 810, in wsdl_parse
    services = self._xml_tree_to_services(wsdl, cache, force_download)
  File "/usr/lib/python2.7/site-packages/PySimpleSOAP-1.16-py2.7.egg/pysimplesoap/client.py", line 759, in _xml_tree_to_services
    binding = ports[port['name']] = copy.deepcopy(bindings[binding_name])
  File "/usr/lib64/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/lib64/python2.7/copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib64/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/lib64/python2.7/copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib64/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/lib64/python2.7/copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib64/python2.7/copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "/usr/lib64/python2.7/copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib64/python2.7/copy.py", line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/lib64/python2.7/copy.py", line 340, in _reconstruct
    value = deepcopy(value, memo)
  File "/usr/lib64/python2.7/copy.py", line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/lib64/python2.7/copy.py", line 341, in _reconstruct
    y[key] = value
  File "/usr/lib/python2.7/site-packages/PySimpleSOAP-1.16-py2.7.egg/pysimplesoap/helpers.py", line 571, in __setitem__
    if key not in self.__keys:
AttributeError: 'Struct' object has no attribute '_Struct__keys'

Original issue reported on code.google.com by rubbersi...@gmail.com on 22 Sep 2014 at 1:35

GoogleCodeExporter commented 8 years ago
Can you test this again?
I've made some fixes, please download the latest version from the repository.
I don't get any error now parsing that WSDL.

Original comment by reingart@gmail.com on 23 Sep 2014 at 5:31