Added "cookies" argument in "getClientWithCookies(...)" function ZTK-1.1
authorThierry Florac <thierry.florac@onf.fr>
Wed, 07 May 2014 19:03:31 +0200
branchZTK-1.1
changeset 248 3d4f38808370
parent 247 a22552ea7d20
child 249 650534afe60d
Added "cookies" argument in "getClientWithCookies(...)" function
src/ztfy/utils/protocol/xmlrpc.py
--- a/src/ztfy/utils/protocol/xmlrpc.py	Fri Jan 17 13:28:49 2014 +0100
+++ b/src/ztfy/utils/protocol/xmlrpc.py	Wed May 07 19:03:31 2014 +0200
@@ -191,10 +191,15 @@
     return xmlrpclib.Server(uri, transport=transport, verbose=verbose, allow_none=allow_none)
 
 
-def getClientWithCookies(uri, credentials=(), verbose=False, allow_none=0, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, headers=None):
+def getClientWithCookies(uri, credentials=(), verbose=False, allow_none=0, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
+                         headers=None, cookies=None):
     """Get an XML-RPC client which supports authentication through cookies"""
+    if cookies is None:
+        cookies = cookielib.CookieJar()
     if uri.startswith('https:'):
-        transport = SecureXMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY secure cookie transport)', credentials, cookielib.CookieJar(), timeout, headers)
+        transport = SecureXMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY secure cookie transport)',
+                                                    credentials, cookies, timeout, headers)
     else:
-        transport = XMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY basic cookie transport)', credentials, cookielib.CookieJar(), timeout, headers)
+        transport = XMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY basic cookie transport)',
+                                              credentials, cookies, timeout, headers)
     return xmlrpclib.Server(uri, transport=transport, verbose=verbose, allow_none=allow_none)