src/ztfy/utils/protocol/xmlrpc.py
branchZTK-1.1
changeset 222 ac6fb60952c9
parent 161 33b95dfd6142
child 223 85a03fd95686
equal deleted inserted replaced
221:4c954a53ac9c 222:ac6fb60952c9
   173 
   173 
   174     _http_connection = httplib.HTTPSConnection
   174     _http_connection = httplib.HTTPSConnection
   175     _http_connection_compat = TimeoutHTTPS
   175     _http_connection_compat = TimeoutHTTPS
   176 
   176 
   177 
   177 
   178 def getClient(uri, credentials=(), verbose=False, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
   178 def getClient(uri, credentials=(), verbose=False, allow_none=0, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
   179     """Get an XML-RPC client which supports basic authentication"""
   179     """Get an XML-RPC client which supports basic authentication"""
   180     if uri.startswith('https:'):
   180     if uri.startswith('https:'):
   181         transport = SecureXMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY secure transport)', credentials, timeout=timeout)
   181         transport = SecureXMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY secure transport)', credentials, timeout=timeout)
   182     else:
   182     else:
   183         transport = XMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY basic transport)', credentials, timeout=timeout)
   183         transport = XMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY basic transport)', credentials, timeout=timeout)
   184     return xmlrpclib.Server(uri, transport=transport, verbose=verbose)
   184     return xmlrpclib.Server(uri, transport=transport, verbose=verbose, allow_none=allow_none)
   185 
   185 
   186 
   186 
   187 def getClientWithCookies(uri, credentials=(), verbose=False, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
   187 def getClientWithCookies(uri, credentials=(), verbose=False, allow_none=0, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
   188     """Get an XML-RPC client which supports authentication throught cookies"""
   188     """Get an XML-RPC client which supports authentication throught cookies"""
   189     if uri.startswith('https:'):
   189     if uri.startswith('https:'):
   190         transport = SecureXMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY secure cookie transport)', credentials, cookielib.CookieJar(), timeout)
   190         transport = SecureXMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY secure cookie transport)', credentials, cookielib.CookieJar(), timeout)
   191     else:
   191     else:
   192         transport = XMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY secure cookie transport)', credentials, cookielib.CookieJar(), timeout)
   192         transport = XMLRPCCookieAuthTransport('Python XML-RPC Client/0.1 (ZTFY secure cookie transport)', credentials, cookielib.CookieJar(), timeout)
   193     return xmlrpclib.Server(uri, transport=transport, verbose=verbose)
   193     return xmlrpclib.Server(uri, transport=transport, verbose=verbose, allow_none=allow_none)