src/ztfy/utils/protocol/xmlrpc.py
branchZTK-1.1
changeset 248 3d4f38808370
parent 223 85a03fd95686
child 265 06d455f32dd5
equal deleted inserted replaced
247:a22552ea7d20 248:3d4f38808370
   189     else:
   189     else:
   190         transport = XMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY basic transport)', credentials, timeout=timeout, headers=headers)
   190         transport = XMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY basic transport)', credentials, timeout=timeout, headers=headers)
   191     return xmlrpclib.Server(uri, transport=transport, verbose=verbose, allow_none=allow_none)
   191     return xmlrpclib.Server(uri, transport=transport, verbose=verbose, allow_none=allow_none)
   192 
   192 
   193 
   193 
   194 def getClientWithCookies(uri, credentials=(), verbose=False, allow_none=0, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, headers=None):
   194 def getClientWithCookies(uri, credentials=(), verbose=False, allow_none=0, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
       
   195                          headers=None, cookies=None):
   195     """Get an XML-RPC client which supports authentication through cookies"""
   196     """Get an XML-RPC client which supports authentication through cookies"""
       
   197     if cookies is None:
       
   198         cookies = cookielib.CookieJar()
   196     if uri.startswith('https:'):
   199     if uri.startswith('https:'):
   197         transport = SecureXMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY secure cookie transport)', credentials, cookielib.CookieJar(), timeout, headers)
   200         transport = SecureXMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY secure cookie transport)',
       
   201                                                     credentials, cookies, timeout, headers)
   198     else:
   202     else:
   199         transport = XMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY basic cookie transport)', credentials, cookielib.CookieJar(), timeout, headers)
   203         transport = XMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY basic cookie transport)',
       
   204                                               credentials, cookies, timeout, headers)
   200     return xmlrpclib.Server(uri, transport=transport, verbose=verbose, allow_none=allow_none)
   205     return xmlrpclib.Server(uri, transport=transport, verbose=verbose, allow_none=allow_none)