Hi All,<br>Got a question:<br><br>I've extended the ElementBase object using the approach described in the tutorial, but SubElement does not work as desired:<br><br>class NodeBase(etree.ElementBase):<br> def append(self,child):<br>
<div style="margin-left: 40px;"> print "aaa"<br> return etree.ElementBase.append(self,child)<br></div><br>etree.SubElement(root,"child") #no "aaa" printed<br><br>OK, but when taking your code to the module:<br>
<br>def SubElement(parent, tag, attrib={}, **extra):<br> attrib = attrib.copy()<br> attrib.update(extra)<br> element = parent.makeelement(tag, attrib)<br> parent.append(element)<br> return element <br><br>
SubElement(root,"child") # "aaa" is here!<br>
<br>and overriding <br> def makeelement(self, tag, attrib):<br> return Node(tag, attrib)<br><br>in the NodeBase just does not help,<br><br>Any advice will be appreciated,<br>Alex