Hi all,

I've started to use spyne 2.9.3 and stumbled upon this: when I use French
characters in the docstring of a function, I get an "AssertionError" when I
try to connect to the service[0]:

>>> from suds.client import Client
>>> c = Client('http://localhost:7789/?wsdl')


ERROR:spyne.server.wsgi:All strings must be XML compatible: Unicode or
ASCII, no NULL bytes or control characters
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/spyne/server/wsgi.py",
line 214, in __handle_wsdl_request
    self.doc.wsdl11.build_interface_document(url)
  File "/usr/local/lib/python2.7/dist-packages/spyne/interface/wsdl/wsdl11.py",
line 237, in build_interface_document
    self.add_port_type(s, root, service_name, types, self.url)
  File "/usr/local/lib/python2.7/dist-packages/spyne/interface/wsdl/wsdl11.py",
line 346, in add_port_type
    documentation.text = method.doc
  File "lxml.etree.pyx", line 904, in lxml.etree._Element.text.__set__
(src/lxml/lxml.etree.c:37197)
  File "apihelpers.pxi", line 721, in lxml.etree._setNodeText
(src/lxml/lxml.etree.c:16865)
  File "apihelpers.pxi", line 1369, in lxml.etree._utf8
(src/lxml/lxml.etree.c:22147)
ValueError: All strings must be XML compatible: Unicode or ASCII, no
NULL bytes or control characters
Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/usr/local/lib/python2.7/dist-packages/spyne/server/wsgi.py",
line 172, in __call__
    return self.__handle_wsdl_request(req_env, start_response, url)
  File "/usr/local/lib/python2.7/dist-packages/spyne/server/wsgi.py",
line 224, in __handle_wsdl_request
    start_response(HTTP_500, ctx.transport.resp_headers.items())
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 178, in start_response
    assert type(val) is StringType,"Header values must be strings"
AssertionError: Header values must be strings

127.0.0.1 - - [20/Nov/2012 17:21:24] "GET /?wsdl HTTP/1.1" 500 59


As far as I am concerned, I produce a lot of code intended for French
speaking maintainers; therefore my docstrings will contain
quite a lot of specific characters like 'é' , 'ê', 'ï', ...

In order to make it work, I modified spyne/interface/wsdl/wsdl11.py like
this:

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

(line 346)
documentation.text = unicode(method.doc)

Of course, the result is the same when just surrounding the docstring
with unicode(). But it felt wrong to me.

Have you got any idea why I get this encoding issue?

Regards,

--
Thomas

[0] I use the example at
https://github.com/arskom/spyne/blob/master/examples/helloworld_soap.py
; just added a special French character in the docstring
_______________________________________________
Soap mailing list
[email protected]
http://mail.python.org/mailman/listinfo/soap

Reply via email to