Package ptree :: Module elements :: Class _ParentedElement
[hide private]
[frames] | no frames]

classobj _ParentedElement

source code


A specialized version of etree.ElementTree.Element that keeps track of a single parent pointer per element.

Each _ParentedElement may have at most one parent. In particular, subtrees may not be shared. Any attempt to reuse a single _ParentedElement as a child of more than one parent (or as multiple children of the same parent) will cause a ValueError exception to be raised.

_ParentedElements should never be used in the same tree as other Element implementation classes. Mixing Element implementations may result in incorrect parent pointers and in ValueError exceptions.

Instance Methods [hide private]
 
__init__(self, tag, attrib) source code
 
parent(self) source code
 
_setparent(self, element)
Update child's parent pointer to point to self.
source code
 
_delparent(self, element)
Remove self from child's parent pointer.
source code
 
makeelement(self, tag, attrib) source code

Inherited from _AbstractParentedElement: __delitem__, __delslice__, __repr__, __setitem__, __setslice__, append, extend, insert, pop, remove

Inherited from xml.etree.ElementTree._ElementInterface: __getitem__, __getslice__, __len__, clear, find, findall, findtext, get, getchildren, getiterator, items, keys, set

Class Variables [hide private]

Inherited from xml.etree.ElementTree._ElementInterface: attrib, tag, tail, text

Method Details [hide private]

__init__(self, tag, attrib)
(Constructor)

source code 
Overrides: xml.etree.ElementTree._ElementInterface.__init__

_setparent(self, element)

source code 

Update child's parent pointer to point to self.

Overrides: _AbstractParentedElement._setparent
(inherited documentation)

_delparent(self, element)

source code 

Remove self from child's parent pointer.

Overrides: _AbstractParentedElement._delparent
(inherited documentation)

makeelement(self, tag, attrib)

source code 
Overrides: xml.etree.ElementTree._ElementInterface.makeelement