def append(self, parent, content): collection = content.value if len(collection): self.suspend(content) for item in collection: cont = Content(tag=content.tag, value=item) Appender.append(self, parent, cont) self.resume(content)
def append(self, parent, content): p = content.value child = self.node(content) child.setText(p.get()) parent.append(child) for item in p.items(): cont = Content(tag=item[0], value=item[1]) Appender.append(self, child, cont)
def append(self, parent, content): d = content.value if self.optional(content) and len(d) == 0: return child = self.node(content) parent.append(child) for item in d.items(): cont = Content(tag=item[0], value=item[1]) Appender.append(self, child, cont)
def append(self, parent, content): object = content.value if self.optional(content) and footprint(object) == 0: return child = self.node(content) parent.append(child) for item in object: cont = Content(tag=item[0], value=item[1]) Appender.append(self, child, cont)
def unmarshall_object(vim, obj): from suds.mx import Content from suds.sax.parser import Parser from suds.bindings.document import Document binding = Document(vim.client.wsdl) marshaller = binding.marshaller() content = Content(obj.__class__.__name__, obj) marshalled_obj = marshaller.process(content) return str(marshalled_obj)
def process(self, value, tag=None): """ Process (marshal) the tag with the specified value using the optional type information. @param value: The value (content) of the XML node. @type value: (L{Object}|any) @param tag: The (optional) tag name for the value. The default is value.__class__.__name__ @type tag: str @return: An xml node. @rtype: L{Element} """ content = Content(tag=tag, value=value) result = Core.process(self, content) return result
def mkparam(self, method, pdef, object): """ Builds a parameter for the specified I{method} using the parameter definition (pdef) and the specified value (object). @param method: A method name. @type method: str @param pdef: A parameter definition. @type pdef: tuple: (I{name}, L{xsd.sxbase.SchemaObject}) @param object: The parameter value. @type object: any @return: The parameter fragment. @rtype: L{Element} """ marshaller = self.marshaller() content = Content(tag=pdef[0], value=object, type=pdef[1], real=pdef[1].resolve()) return marshaller.process(content)
def mkheader(self, method, hdef, object): """ Builds a soapheader for the specified I{method} using the header definition (hdef) and the specified value (object). @param method: A method name. @type method: str @param hdef: A header definition. @type hdef: tuple: (I{name}, L{xsd.sxbase.SchemaObject}) @param object: The header value. @type object: any @return: The parameter fragment. @rtype: L{Element} """ marshaller = self.marshaller() if isinstance(object, (list, tuple)): return [self.mkheader(method, hdef, item) for item in object] content = Content(tag=hdef[0], value=object, type=hdef[1]) return marshaller.process(content)