def marshall(self, name, value, add_child=True, add_comments=False,
                 ns=False, add_children_ns=True):
        """Analyze python value and add the serialized XML element using tag name"""
        # Change node name to that used by a client
        name = self._update_ns(name)

        if isinstance(value, dict):  # serialize dict (<key>value</key>)
            # for the first parent node, use the document target namespace
            # (ns==True) or use the namespace string uri if passed (elements)
            child = add_child and self.add_child(name, ns=ns) or self
            for k, v in value.items():
                if not add_children_ns:
                    ns = False
                else:
                    # for children, use the wsdl element target namespace:
                    ns = getattr(value, 'namespace', None)
                child.marshall(k, v, add_comments=add_comments, ns=ns)
        elif isinstance(value, tuple):  # serialize tuple (<key>value</key>)
            child = add_child and self.add_child(name, ns=ns) or self
            if not add_children_ns:
                ns = False
            for k, v in value:
                getattr(self, name).marshall(k, v, add_comments=add_comments, ns=ns)
        elif isinstance(value, list):  # serialize lists
            child = self.add_child(name, ns=ns)
            if not add_children_ns:
                ns = False
            if add_comments:
                child.add_comment("Repetitive array of:")
            for t in value:
                child.marshall(name, t, False, add_comments=add_comments, ns=ns)
        elif isinstance(value, basestring):  # do not convert strings or unicodes
            self.add_child(name, value, ns=ns)
        elif value is None:  # sent a empty tag?
            self.add_child(name, ns=ns)
        elif value in TYPE_MAP.keys():
            # add commented placeholders for simple tipes (for examples/help only)
            child = self.add_child(name, ns=ns)
            child.add_comment(TYPE_MAP[value])
        else:  # the rest of object types are converted to string
            # get special serialization function (if any)
            fn = TYPE_MARSHAL_FN.get(type(value), str)
            self.add_child(name, fn(value), ns=ns)
dataset/ETHPy150Open uwdata/termite-data-server/web2py/gluon/contrib/pysimplesoap/simplexml.py/SimpleXMLElement.marshall/original