ó i'dWc@sFdZddlmZddlmZmZdefd„ƒYZdS(sKDefines the SimpleXmlHandlerBase class to convert simple XML to DataObject i’’’’(tetree(t DataObjectt ParsingErrortSimpleXmlHandlerBasecBsGeZdZdZdd„Zd„Zed„ƒZed„ƒZ RS(sūSimple XML handling DataObject base-class. Not to be instantiated directly, should be sub-classed. Converts a simple xml tag (e.g. ) to a DataObject, if there is a name attribute in the tag, then it will be used as the name of the DataObject. To make it work, you need to sub-class it and redefine the value of TAG_NAME to match the XML tag, e.g.: from solaris_install.data_object.simple import SimpleXmlHandlerBase # Define the class class MyTag(SimpleXmlHandlerBase): TAG_NAME="mytag" # Register with DOC so that it will be used. DataObjectCache.register_class(MyTag) and that's it, this will take an XML tag like the following: ... and generate a DataObject for storage in the Data Object Cache. The main reason you might do this is to place a set of sub-tags into a specific location in the DOC. cCs8|jdkrtdƒ‚ntt|ƒj|ƒdS(NsTAG_NAME should not be None.(tTAG_NAMEtNonet ValueErrortsuperRt__init__(tselftname((s simple.pyRFscCsGtj|jƒ}|jrC|j|jkrC|jd|jƒn|S(s Generate XMLR (RtElementRR tset(R telem((s simple.pytto_xmlLscCs|j|jkrtStS(s!Check if XML tag matches TAG_NAME(ttagRtFalsetTrue(tclstelement((s simple.pyt can_handleUscCs\|j|jkr1td|j|jfƒ‚n|jdƒ}|sR|j}n||ƒS(sŌConvert XML tag to a DataObject. If there is a name attribute in the XML tag, then we will use that as the name of the object for insertion in the the Data Object Cache. sTag name %s != %sR (RRRtget(RRR ((s simple.pytfrom_xml\s  N( t__name__t __module__t__doc__RRRRt classmethodRR(((s simple.pyR"s    N(RtlxmlRtsolaris_install.data_objectRRR(((s simple.pyts