1 May 20:14
Custom Elements question
From: Alex Klizhentas <klizhentas <at> gmail.com>
Subject: Custom Elements question
Newsgroups: gmane.comp.python.lxml.devel
Date: 2008-05-01 18:14:19 GMT
Subject: Custom Elements question
Newsgroups: gmane.comp.python.lxml.devel
Date: 2008-05-01 18:14:19 GMT
Hi All,
Got a question:
I've extended the ElementBase object using the approach described in the tutorial, but SubElement does not work as desired:
class NodeBase(etree.ElementBase):
def append(self,child):
print "aaa"
return etree.ElementBase.append(self,child)
return etree.ElementBase.append(self,child)
etree.SubElement(root,"child") #no "aaa" printed
OK, but when taking your code to the module:
def SubElement(parent, tag, attrib={}, **extra):
attrib = attrib.copy()
attrib.update(extra)
element = parent.makeelement(tag, attrib)
parent.append(element)
return element
SubElement(root,"child") # "aaa" is here!
and overriding
def makeelement(self, tag, attrib):
return Node(tag, attrib)
in the NodeBase just does not help,
Any advice will be appreciated,
Alex
_______________________________________________ lxml-dev mailing list lxml-dev <at> codespeak.net http://codespeak.net/mailman/listinfo/lxml-dev
RSS Feed