[spyne] String constraints and enums

Burak Arslan burak.arslan at arskom.com.tr
Tue Jun 17 15:09:40 UTC 2014


Hi Alex,

The request for

    @rpc(RequestStatus, _returns=Integer)
    def DemoFunction(ctx, data):

is:

{"DemoFunction": {"data": "whatever"}}

So Spyne seems to be doing the right thing here. It should do the same
thing every time though, are you sure you're sending the same document
every time?.. Can you reproduce this with curl as well?

$ curl -d '{"DemoFunction": {"data": "new"}}' http://localhost:8000
4
$ curl -d '{"DemoFunction": {"data": "whatever"}}' http://localhost:8000
{"faultcode": "Client.ValidationError", "faultstring": "The value
\"('data', u'whatever')\" could not be validated."}

Best regards,
Burak

On 06/17/14 15:52, Alex wrote:
> Attached is an example that replicates the problem, the code is also
> available here: http://pastebin.com/L0UC6pzh
>
>
> This is an example of what happens:
> telnet 127.0.0.1 8000
> Trying 127.0.0.1...
> Connected to 127.0.0.1.
> Escape character is '^]'.
> POST / HTTP/1.1
> Host: localhost
> Content-Length: 42
>
> {"DemoFunction":{"data":{"status":"new"}}}
> HTTP/1.0 400 Bad Request
> Date: Tue, 17 Jun 2014 12:46:01 GMT
> Server: WSGIServer/0.1 Python/2.7.4
> Content-Length: 131
> Content-Type: application/json
>
> {"faultcode": "Client.ValidationError", "faultstring": "The value
> \"{u'status': u'new'}\" could not be validated.", "detail":
> null}Connection closed by foreign host.
>
>
>
>
>
> Here's the weird part, when I first ran it - it worked as expected. I
> then gave it another try and the problem persists ever since.
> Fortunately my terminal log confirms that it did behave correctly
> once, printing `4` the first time:
>
> alex at ralien ~/dk_cvs/Netopay/WebAPI/src $ telnet 127.0.0.1 8000
> Trying 127.0.0.1...
> Connected to 127.0.0.1.
> Escape character is '^]'.
> POST / HTTP/1.1
> Host: localhost
> Content-Length: 42
>
> {"DemoFunction":{"data":{"status":"new"}}}
> HTTP/1.0 200 OK
> Date: Tue, 17 Jun 2014 12:34:46 GMT
> Server: WSGIServer/0.1 Python/2.7.4
> Content-Type: application/json
>
> 4Connection closed by foreign host.
> alex at ralien ~/dk_cvs/Netopay/WebAPI/src $ telnet 127.0.0.1 8000
> Trying 127.0.0.1...
> Connected to 127.0.0.1.
> Escape character is '^]'.
> POST / HTTP/1.1
> Host: localhost
> Content-Length: 42
>
> {"DemoFunction":{"data":{"status":"new"}}}
> HTTP/1.0 400 Bad Request
> Date: Tue, 17 Jun 2014 12:35:53 GMT
> Server: WSGIServer/0.1 Python/2.7.4
> Content-Length: 131
> Content-Type: application/json
>
> {"faultcode": "Client.ValidationError", "faultstring": "The value
> \"{u'status': u'new'}\" could not be validated.", "detail":
> null}Connection closed by foreign host.
>
>
> _______________________________________________
> Spyne community mailing list
> people at spyne.io
> http://lists.spyne.io/listinfo/people

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spyne.io/archives/people/attachments/20140617/93206031/attachment.html>


More information about the people mailing list