libsolace.SolaceXMLBuilder module¶
-
class
libsolace.SolaceXMLBuilder.
SolaceXMLBuilder
(description=None, version=None, **kwargs)[source]¶ Bases:
object
Builds Solace’s SEMP XML Configuration Commands
Creating a instance of this, and then calling any obj on the instance, will create nested XML tags if the element does not exist, or return the element if it does exist for recursive instantiation.
THe only limitatoin here is that there can only be ONE root node, “foo” in the example below.
Example
>>> from libsolace.SolaceXMLBuilder import SolaceXMLBuilder >>> a=SolaceXMLBuilder(version="soltr/6_2") >>> a.foo.bar.baz=2 >>> a.foo.banana OrderedDict() >>> str(a) '<rpc semp-version="soltr/6_2"><foo><bar><baz>2</baz></bar><banana/></foo></rpc>' >>> a.bar.zoo = 2 # different ROOT will break repr >>> str(a) ERROR:root:the root leaf node was not found, maybe you registered two roots! Traceback (most recent call last): File "<stdin>", line 1, in <module> File "libsolace/SolaceXMLBuilder.py", line 60, in __repr__ complete_xml = str('<rpc semp-version="%s">%s</rpc>' % (self.version, myxml.display(version=self.version))) File "libsolace/util.py", line 178, in display complete_xml = str('
<rpc semp-version=”%s”> %s</rpc>’ % (version, self.root.toprettyxml(indent=” ”)))
AttributeError: d2x instance has no attribute ‘root’