Using Python Spyne (RPC) is there a way to return a native python list instead of the fancy Array or Iterable? -


both iterable , array types seem have native list hidden away in them, find myself doing things like:

mylist = service.fetchremotelist()[0][1]  

where fetchremotelist() _returns=iterable(string)

i don't want have put [0][1] @ end of list function calls.

spyne uses wrapped arrays default, because that's else in xml world does.

wrapped array:

<users>     <user>         <id>1</id>         <name>batman</name>     </user>     <user>         <id>2</id>         <name>robin</name>     </user> </users> 

bare array:

<users>     <id>1</id>     <name>batman</name> </users> <users>     <id>2</id>     <name>robin</name> </users> 

you can see why likes wrapped arrays better now. it's matter of convention, surely helpful one. plus, it's not possible polymorphism non-wrapped arrays.

spyne uses wrapped functions default, because it's not possible have multiple arguments / return values in bare mode.

now answers:

  • here's wrapped array:

    array(unicode) 

    here's equivalent bare array:

    unicode(max_occurs='unbounded') 

    in 2.12, can pass wrapped=false array bare arrays. eg.:

    array(unicode, wrapped=false) 
  • as discovered, can bare functions passing _body_style='bare' @rpc.

some soap clients discover kind of function/array via simple heuristics , save trouble of using magic indexes. apparently suds isn't 1 of them.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -