本文整理匯總了Python中_beatbox.Client類的典型用法代碼示例。如果您正苦於以下問題:Python Client類的具體用法?Python Client怎麽用?Python Client使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Client類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: describeGlobal
def describeGlobal(self):
res = BaseClient.describeGlobal(self)
data = dict()
data['encoding'] = str(res[_tPartnerNS.encoding])
data['maxBatchSize'] = int(str(res[_tPartnerNS.maxBatchSize]))
data['types'] = [str(t) for t in res[_tPartnerNS.types:]]
return data
示例2: query
def query(self, *args, **kw):
if len(args) == 1: # full query string
queryString = args[0]
elif len(args) == 2: # BBB: fields, sObjectType
queryString = 'select %s from %s' % (args[0], args[1])
if 'conditionalExpression' in kw: # BBB: fields, sObjectType, conditionExpression as kwarg
queryString += ' where %s' % (kw['conditionalExpression'])
elif len(args) == 3: # BBB: fields, sObjectType, conditionExpression as positional arg
whereClause = args[2] and (' where %s' % args[2]) or ''
queryString = 'select %s from %s%s' % (args[0], args[1], whereClause)
else:
raise RuntimeError("Wrong number of arguments to query method.")
res = BaseClient.query(self, queryString)
# calculate the union of the sets of record types from each record
types = reduce(lambda a, b: a|b, [getRecordTypes(r) for r in res[_tPartnerNS.records:]], set())
if not self.cacheTypeDescriptions:
self.flushTypeDescriptionsCache()
new_types = types - set(self.typeDescs.keys())
if new_types:
self.typeDescs.update(self.queryTypesDescriptions(new_types))
data = QueryRecordSet(
records=[self._extractRecord(r) for r in res[_tPartnerNS.records:]],
done=_bool(res[_tPartnerNS.done]),
size=int(str(res[_tPartnerNS.size])),
queryLocator=str(res[_tPartnerNS.queryLocator]))
return data
示例3: useSession
def useSession(self, sessionId, serverUrl):
if ( str(sessionId) == '' or str(serverUrl) == '' ):
raise AttributeError , 'Missing server url or session ID to useSession method'
logging.info( sessionId, serverUrl)
res = BaseClient.useSession(self, sessionId, serverUrl)
data = dict()
data['sessionId'] = sessionId
return data
示例4: login
def login(self, username, passwd):
res = BaseClient.login(self, username, passwd)
data = dict()
data['passwordExpired'] = _bool(res[_tPartnerNS.passwordExpired])
data['serverUrl'] = str(res[_tPartnerNS.serverUrl])
data['sessionId'] = str(res[_tPartnerNS.sessionId])
data['userId'] = str(res[_tPartnerNS.userId])
data['userInfo'] = _extractUserInfo(res[_tPartnerNS.userInfo])
return data
示例5: describeTabs
def describeTabs(self):
res = BaseClient.describeTabs(self)
data = list()
for r in res:
tabs = [_extractTab(t) for t in r[_tPartnerNS.tabs:]]
d = dict(
label = str(r[_tPartnerNS.label]),
logoUrl = str(r[_tPartnerNS.logoUrl]),
selected = _bool(r[_tPartnerNS.selected]),
tabs=tabs)
return data
示例6: query
def query(self, queryString):
res = BaseClient.query(self, queryString)
locator = QueryLocator( str(res[_tPartnerNS.queryLocator]) )
data = dict(queryLocator = locator,
done = _bool(res[_tPartnerNS.done]),
records = [self.extractRecord( r )
for r in res[_tPartnerNS.records:]],
size = int(str(res[_tPartnerNS.size]))
)
return data
示例7: queryMore
def queryMore(self, queryLocator):
locator = queryLocator
res = BaseClient.queryMore(self, locator)
# calculate the union of the sets of record types from each record
types = reduce(lambda a,b: a|b, [getRecordTypes(r) for r in res[_tPartnerNS.records:]], set())
new_types = types - set(self.typeDescs.keys())
if new_types:
self.typeDescs.update(self.queryTypesDescriptions(new_types))
data = QueryRecordSet(records=[self._extractRecord(r) for r in res[_tPartnerNS.records:]],
done=_bool(res[_tPartnerNS.done]),
size=int(str(res[_tPartnerNS.size])),
queryLocator = str(res[_tPartnerNS.queryLocator]))
return data
示例8: getDeleted
def getDeleted(self, sObjectType, start, end):
res = BaseClient.getDeleted(self, sObjectType, start, end)
res = res[_tPartnerNS.deletedRecords:]
if type(res) not in (TupleType, ListType):
res = [res]
data = list()
for r in res:
d = dict(
id = str(r[_tPartnerNS.id]),
deletedDate = marshall('datetime', 'deletedDate', r,
ns=_tPartnerNS))
data.append(d)
return data
示例9: queryMore
def queryMore(self, queryLocator):
locator = queryLocator.locator
#sObjectType = queryLocator.sObjectType
#fields = queryLocator.fields
res = BaseClient.queryMore(self, locator)
locator = QueryLocator( str(res[_tPartnerNS.queryLocator]) )
data = dict(queryLocator = locator,
done = _bool(res[_tPartnerNS.done]),
records = [_extractRecord( r )
for r in res[_tPartnerNS.records:]],
size = int(str(res[_tPartnerNS.size]))
)
return data
示例10: describeSObjects
def describeSObjects(self, sObjectTypes):
res = BaseClient.describeSObjects(self, sObjectTypes)
if type(res) not in (TupleType, ListType):
res = [res]
data = list()
for r in res:
d = dict()
d['activateable'] = _bool(r[_tPartnerNS.activateable])
rawreldata = r[_tPartnerNS.ChildRelationships:]
relinfo = [_extractChildRelInfo(cr) for cr in rawreldata]
d['ChildRelationships'] = relinfo
d['createable'] = _bool(r[_tPartnerNS.createable])
d['custom'] = _bool(r[_tPartnerNS.custom])
try:
d['customSetting'] = _bool(r[_tPartnerNS.customSetting])
except KeyError:
pass
d['deletable'] = _bool(r[_tPartnerNS.deletable])
d['deprecatedAndHidden'] = _bool(r[_tPartnerNS.deprecatedAndHidden])
try:
d['feedEnabled'] = _bool(r[_tPartnerNS.feedEnabled])
except KeyError:
pass
fields = r[_tPartnerNS.fields:]
fields = [_extractFieldInfo(f) for f in fields]
field_map = dict()
for f in fields:
field_map[f.name] = f
d['fields'] = field_map
d['keyPrefix'] = str(r[_tPartnerNS.keyPrefix])
d['label'] = str(r[_tPartnerNS.label])
d['labelPlural'] = str(r[_tPartnerNS.labelPlural])
d['layoutable'] = _bool(r[_tPartnerNS.layoutable])
d['mergeable'] = _bool(r[_tPartnerNS.mergeable])
d['name'] = str(r[_tPartnerNS.name])
d['queryable'] = _bool(r[_tPartnerNS.queryable])
d['recordTypeInfos'] = [_extractRecordTypeInfo(rti) for rti in r[_tPartnerNS.recordTypeInfos:]]
d['replicateable'] = _bool(r[_tPartnerNS.replicateable])
d['retrieveable'] = _bool(r[_tPartnerNS.retrieveable])
d['searchable'] = _bool(r[_tPartnerNS.searchable])
try:
d['triggerable'] = _bool(r[_tPartnerNS.triggerable])
except KeyError:
pass
d['undeletable'] = _bool(r[_tPartnerNS.undeletable])
d['updateable'] = _bool(r[_tPartnerNS.updateable])
d['urlDetail'] = str(r[_tPartnerNS.urlDetail])
d['urlEdit'] = str(r[_tPartnerNS.urlEdit])
d['urlNew'] = str(r[_tPartnerNS.urlNew])
data.append(SObject(**d))
return data
示例11: search
def search(self, sosl):
res = BaseClient.search(self, sosl)
if not self.cacheTypeDescriptions:
self.flushTypeDescriptionsCache()
# calculate the union of the sets of record types from each record
if len(res):
types = reduce(lambda a,b: a|b, [getRecordTypes(r) for r in res[_tPartnerNS.searchRecords]], set())
new_types = types - set(self.typeDescs.keys())
if new_types:
self.typeDescs.update(self.queryTypesDescriptions(new_types))
return [self._extractRecord(r) for r in res[_tPartnerNS.searchRecords]]
else:
return []
示例12: query_old
def query_old(self, fields, sObjectType, conditionExpression=''):
#type_data = self.describeSObjects(sObjectType)[0]
queryString = 'select %s from %s' % (fields, sObjectType)
if conditionExpression: queryString = '%s where %s' % (queryString, conditionExpression)
fields = [f.strip() for f in fields.split(',')]
res = BaseClient.query(self, queryString)
locator = QueryLocator( str(res[_tPartnerNS.queryLocator]), )
data = dict(queryLocator = locator,
done = _bool(res[_tPartnerNS.done]),
records = [self.extractRecord( r )
for r in res[_tPartnerNS.records:]],
size = int(str(res[_tPartnerNS.size]))
)
return data
示例13: delete
def delete(self, ids):
res = BaseClient.delete(self, ids)
if type(res) not in (TupleType, ListType):
res = [res]
data = list()
for r in res:
d = dict()
data.append(d)
d['id'] = str(r[_tPartnerNS.id])
d['success'] = success = _bool(r[_tPartnerNS.success])
if not success:
d['errors'] = [_extractError(e)
for e in r[_tPartnerNS.errors:]]
else:
d['errors'] = list()
return data
示例14: retrieve
def retrieve(self, fields, sObjectType, ids):
resultSet = BaseClient.retrieve(self, fields, sObjectType, ids)
type_data = self.describeSObjects(sObjectType)[0]
if type(resultSet) not in (TupleType, ListType):
if isnil(resultSet):
resultSet = list()
else:
resultSet = [resultSet]
fields = [f.strip() for f in fields.split(',')]
data = list()
for result in resultSet:
d = dict()
data.append(d)
for fname in fields:
d[fname] = type_data.marshall(fname, result)
return data
示例15: describeSObjects
def describeSObjects(self, sObjectTypes):
if (self.describeCache.has_key(sObjectTypes)):
data = list()
data.append(self.describeCache[sObjectTypes])
return data
res = BaseClient.describeSObjects(self, sObjectTypes)
if type(res) not in (TupleType, ListType):
res = [res]
data = list()
for r in res:
d = dict()
d['activateable'] = _bool(r[_tPartnerNS.activateable])
d['createable'] = _bool(r[_tPartnerNS.createable])
d['custom'] = _bool(r[_tPartnerNS.custom])
d['deletable'] = _bool(r[_tPartnerNS.deletable])
fields = r[_tPartnerNS.fields:]
fields = [_extractFieldInfo(f) for f in fields]
field_map = dict()
for f in fields:
field_map[f.name] = f
d['fields'] = field_map
rawreldata = r[_tPartnerNS.ChildRelationships:]
# why is this list empty ?
# print repr(rawreldata)
relinfo = [_extractChildRelInfo(cr) for cr in rawreldata]
d['ChildRelationships'] = relinfo
d['keyPrefix'] = str(r[_tPartnerNS.keyPrefix])
d['label'] = str(r[_tPartnerNS.label])
d['labelPlural'] = str(r[_tPartnerNS.labelPlural])
d['layoutable'] = _bool(r[_tPartnerNS.layoutable])
d['name'] = str(r[_tPartnerNS.name])
d['queryable'] = _bool(r[_tPartnerNS.queryable])
d['replicateable'] = _bool(r[_tPartnerNS.replicateable])
d['retrieveable'] = _bool(r[_tPartnerNS.retrieveable])
d['searchable'] = _bool(r[_tPartnerNS.searchable])
d['undeletable'] = _bool(r[_tPartnerNS.undeletable])
d['updateable'] = _bool(r[_tPartnerNS.updateable])
d['urlDetail'] = str(r[_tPartnerNS.urlDetail])
d['urlEdit'] = str(r[_tPartnerNS.urlEdit])
d['urlNew'] = str(r[_tPartnerNS.urlNew])
data.append(SObject(**d))
self.describeCache[str(r[_tPartnerNS.name])] = SObject(**d)
return data