本文整理匯總了Python中suds.client.Client.clone方法的典型用法代碼示例。如果您正苦於以下問題:Python Client.clone方法的具體用法?Python Client.clone怎麽用?Python Client.clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類suds.client.Client
的用法示例。
在下文中一共展示了Client.clone方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: SforceBaseClient
# 需要導入模塊: from suds.client import Client [as 別名]
# 或者: from suds.client.Client import clone [as 別名]
class SforceBaseClient(object):
_sforce = None
_sessionId = None
_location = None
_product = 'Python Toolkit'
_version = (0, 1, 3)
_objectNamespace = None
_strictResultTyping = False
_allowFieldTruncationHeader = None
_assignmentRuleHeader = None
_callOptions = None
_assignmentRuleHeader = None
_emailHeader = None
_localeOptions = None
_loginScopeHeader = None
_mruHeader = None
_packageVersionHeader = None
_queryOptions = None
_sessionHeader = None
_userTerritoryDeleteHeader = None
def __init__(self, wsdl=None, cacheDuration = 0, suds_client=None, **kwargs):
'''
Connect to Salesforce
'wsdl' : Location of WSDL
'cacheDuration' : Duration of HTTP GET cache in seconds, or 0 for no cache
'proxy' : Dict of pair of 'protocol' and 'location'
e.g. {'http': 'my.insecure.proxy.example.com:80'}
'username' : Username for HTTP auth when using a proxy ONLY
'password' : Password for HTTP auth when using a proxy ONLY
'''
if suds_client is None:
# Suds can only accept WSDL locations with a protocol prepended
if '://' not in wsdl:
# TODO windows users???
# check if file exists, else let bubble up to suds as is
# definitely don't want to assume http or https
if os.path.isfile(wsdl):
wsdl = 'file://' + os.path.abspath(wsdl)
if cacheDuration > 0:
cache = FileCache()
cache.setduration(seconds = cacheDuration)
else:
cache = None
self._sforce = Client(wsdl, cache = cache)
# Set HTTP headers
headers = {'User-Agent': 'Salesforce/' + self._product + '/' + '.'.join(str(x) for x in self._version)}
# This HTTP header will not work until Suds gunzips/inflates the content
# 'Accept-Encoding': 'gzip, deflate'
self._sforce.set_options(headers = headers)
if kwargs.has_key('proxy'):
# urllib2 cannot handle HTTPS proxies yet (see bottom of README)
if kwargs['proxy'].has_key('https'):
raise NotImplementedError('Connecting to a proxy over HTTPS not yet implemented due to a \
limitation in the underlying urllib2 proxy implementation. However, traffic from a proxy to \
Salesforce will use HTTPS.')
self._sforce.set_options(proxy = kwargs['proxy'])
if kwargs.has_key('username'):
self._sforce.set_options(username = kwargs['username'])
if kwargs.has_key('password'):
self._sforce.set_options(password = kwargs['password'])
else:
self._sforce = suds_client
def clone(self):
return type(self)(suds_client=self._sforce.clone())
# Toolkit-specific methods
def generateHeader(self, sObjectType):
'''
Generate a SOAP header as defined in:
http://www.salesforce.com/us/developer/docs/api/Content/soap_headers.htm
'''
try:
return self._sforce.factory.create(sObjectType)
except:
print 'There is not a SOAP header of type %s' % sObjectType
def generateObject(self, sObjectType):
'''
Generate a Salesforce object, such as a Lead or Contact
'''
obj = self._sforce.factory.create('ens:sObject')
obj.type = sObjectType
return obj
def _handleResultTyping(self, result):
'''
#.........這裏部分代碼省略.........