def chunkRequests(self, collection, chunkLength=None): if not islst(collection): yield [collection] else: if chunkLength is None: chunkLength = self.batchSize for i in xrange(0, len(collection), chunkLength): yield collection[i:i + chunkLength]
def writeStringElement(self, namespace, name, value, attrs=_noAttrs): if islst(value): for v in value: self.writeStringElement(namespace, name, v, attrs) else: self.startElement(namespace, name, attrs) self.characters(value) self.endElement()
def chunkRequests(self, collection, chunkLength=None): if not islst(collection): yield [collection] else: if chunkLength is None: chunkLength = self.batchSize for i in xrange(0, len(collection), chunkLength): yield collection[i:i+chunkLength]
def writeSObjects(self, s, sObjects, elemName="sObjects"): if islst(sObjects): for o in sObjects: self.writeSObjects(s, o, elemName) else: s.startElement(_partnerNs, elemName) # type has to go first s.writeStringElement(_sobjectNs, "type", sObjects['type']) for fn in sObjects.keys(): if (fn != 'type'): s.writeStringElement(_sobjectNs, fn, sObjects[fn]) s.endElement()
def writeDict(self, s, elemName, d): if islst(d): for o in d: self.writeDict(s, elemName, o) else: s.startElement(_partnerNs, elemName) for fn in d.keys(): if (isinstance(d[fn], dict)): self.writeDict(s, d[fn], fn) else: s.writeStringElement(_sobjectNs, fn, d[fn]) s.endElement()
def writeElement(self, namespace, name, value, attrs = _noAttrs): if islst(value): for v in value: self.writeElement(namespace, name, v, attrs) elif isinstance(value, dict): self.startElement(namespace, name, attrs) # Type must always come first, even in embedded objects. type_entry = value['type'] self.writeElement(namespace, 'type', type_entry, attrs) del value['type'] for k, v in value.items(): self.writeElement(namespace, k, v, attrs) self.endElement() else: self.startElement(namespace, name, attrs) self.characters(value) self.endElement()
def writeElement(self, namespace, name, value, attrs=_noAttrs): if islst(value): for v in value: self.writeElement(namespace, name, v, attrs) elif isinstance(value, dict): self.startElement(namespace, name, attrs) if 'type' in value: # Type must always come first, even in embedded objects. type_entry = value['type'] self.writeElement(namespace, 'type', type_entry, attrs) del value['type'] for k, v in value.items(): self.writeElement(namespace, k, v, attrs) self.endElement() else: self.startElement(namespace, name, attrs) self.characters(value) self.endElement()
def writeBody(self, s): if (islst(self.__actions)): for action in self.__actions: self.writeQuckAction(s, action) else: self.writeQuickAction(s, self.__actions)