[Soap-Python] Spyne and the basic use of Arrays

C Anthony Risinger anthony.risinger at corvisa.com
Thu Aug 30 20:50:26 CEST 2012


On 08/30/2012 01:39 PM, Alex Railean wrote:
> Hi, thank you for the help
>
>> result.results.append(resultElement)
> I tried that as well, but this doesn't work:
>
> (Pdb) result.results.append(resultElement)
> *** AttributeError: 'NoneType' object has no attribute 'append'

hmm, yes i think it's suppose to be an empty list by default, but it's 
been a little while since i was in that code.

under the hood, the library is just creating a container for you, so at 
the and of the day you can do the same if need be, eg:

     class SearchResultArray(ComplexModel)

         results = SearchResult(max_occurs='unbounded')

... note the syntax changed recently that might be wrong (could be 
Decimal('inf') or some such)

also try adding `max_occurs` to the Array:

results = Array(SearchResult, max_occurs='unbounded')

... last but not least, try to just assign a list to the attribute:

     result = DSearchResponse()
     result.results = []
     resultElement = SearchResult()
     resultElement.subjectName = 'dummy'
     result.results.append(resultElement)   # <--- ouch!
     return result

-- 

C Anthony

-----------------------------------------
CONFIDENTIALITY: The information contained in this communication may be confidential and is intended only for the use of the intended recipient(s). If the reader of this message is not the intended recipient(s), you are hereby notified that
any dissemination, distribution, or copying of this communication, or any of its contents, is strictly prohibited. If you have received this communication in error, please return it to the sender immediately and delete any copy of it from your computer system.


More information about the Soap mailing list