Skip to content

AttributeError: 'RefElement' object has no attribute 'attr_name' #377

@hierchristian

Description

@hierchristian

Hello,

thanks for the great work. Usually not having any problems with zeep.

Actually I have a problem parsing a response. So I upgraded zeep in order to try the strict mode.
But after upgrading I am getting following error:

> File "pay.py", line 50, in <module>
    CompleteType='NotComplete')
  File "/usr/local/lib/python2.7/dist-packages/zeep/xsd/types/complex.py", line 39, in __call__
    return self._value_class(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/zeep/xsd/valueobjects.py", line 44, in __init__
    elm_values = container.default_value
  File "/usr/local/lib/python2.7/dist-packages/cached_property.py", line 53, in __get__
    return obj_dict.setdefault(name, self.func(obj))
  File "/usr/local/lib/python2.7/dist-packages/zeep/xsd/elements/indicators.py", line 27, in default_value
    (name, element.default_value) for name, element in self.elements
  File "/usr/local/lib/python2.7/dist-packages/cached_property.py", line 53, in __get__
    return obj_dict.setdefault(name, self.func(obj))
  File "/usr/local/lib/python2.7/dist-packages/zeep/xsd/elements/indicators.py", line 54, in elements
    for name, elm in self.elements_nested:
  File "/usr/local/lib/python2.7/dist-packages/cached_property.py", line 53, in __get__
    return obj_dict.setdefault(name, self.func(obj))
  File "/usr/local/lib/python2.7/dist-packages/zeep/xsd/elements/indicators.py", line 79, in elements_nested
    name = generator_2.create_name(elm.attr_name)
AttributeError: 'RefElement' object has no attribute 'attr_name'

Here's the code:

c = Client('https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl')

s = c.create_service('{urn:ebay:api:PayPalAPI}PayPalAPIAASoapBinding', 'https://api-3t.sandbox.paypal.com/2.0/')

headerType = c.get_element('ns0:RequesterCredentials')

header = headerType(Credentials={
  'Username': 'xxx',
  'Password': 'xxx',
  'Signature': 'xxx'
})

c.set_default_soapheaders([header])

reqType = c.get_type('ns0:DoCaptureRequestType')

amountType = c.get_type('ns1:BasicAmountType')

request = reqType(
  Version='2.04',
  AuthorizationID='xxx',
  Amount=amountType('100.0', currencyID='EUR'),
  CompleteType='NotComplete'
)

print s.DoCapture(request)

Since the code worked before the upgrade it may be a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions