pythonweb-servicescookiessoappyzsi

Adding Cookie to ZSI Posts


I've added cookie support to SOAPpy by overriding HTTPTransport. I need functionality beyond that of SOAPpy, so I was planning on moving to ZSI, but I can't figure out how to put the Cookies on the ZSI posts made to the service. Without these cookies, the server will think it is an unauthorized request and it will fail.

How can I add cookies from a Python CookieJar to ZSI requests?


Solution

  • If you read the _Binding class in client.py of ZSI you can see that it has a variable cookies, which is an instance of Cookie.SimpleCookie. Following the ZSI example and the Cookie example that is how it should work:

    b = Binding(url='/cgi-bin/simple-test', tracefile=fp)
    b.cookies['foo'] = 'bar'