diff options
author | Fred Drake <fdrake@acm.org> | 2001-04-04 15:15:18 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-04-04 15:15:18 (GMT) |
commit | 33d2b84b2c420ef6e182aa6c6c91cb7844d9994c (patch) | |
tree | 8a3649aa64db78210e85349ec906ba3e6d1742ca /Lib/xml/dom | |
parent | 87432f42f953920912b9780f0ae0d7c41cb349f2 (diff) | |
download | cpython-33d2b84b2c420ef6e182aa6c6c91cb7844d9994c.zip cpython-33d2b84b2c420ef6e182aa6c6c91cb7844d9994c.tar.gz cpython-33d2b84b2c420ef6e182aa6c6c91cb7844d9994c.tar.bz2 |
CharacterData methods: Update self.length on changes instead of extended
the __getattr__() handler.
Text.splitText(): Update the length and nodeValue attributes.
Diffstat (limited to 'Lib/xml/dom')
-rw-r--r-- | Lib/xml/dom/minidom.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 26923b5..628a375 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -619,10 +619,7 @@ class CharacterData(Node): raise TypeError, "node contents must be a string" Node.__init__(self) self.data = self.nodeValue = data - - def __getattr__(self, name): - if name == "length": - return len(self.data) + self.length = len(data) def __repr__(self): if len(self.data) > 10: @@ -644,6 +641,7 @@ class CharacterData(Node): def appendData(self, arg): self.data = self.data + arg self.nodeValue = self.data + self.length = len(self.data) def insertData(self, offset, arg): if offset < 0: @@ -654,6 +652,7 @@ class CharacterData(Node): self.data = "%s%s%s" % ( self.data[:offset], arg, self.data[offset:]) self.nodeValue = self.data + self.length = len(self.data) def deleteData(self, offset, count): if offset < 0: @@ -665,6 +664,7 @@ class CharacterData(Node): if count: self.data = self.data[:offset] + self.data[offset+count:] self.nodeValue = self.data + self.length = len(self.data) def replaceData(self, offset, count, arg): if offset < 0: @@ -677,6 +677,7 @@ class CharacterData(Node): self.data = "%s%s%s" % ( self.data[:offset], arg, self.data[offset+count:]) self.nodeValue = self.data + self.length = len(self.data) class Text(CharacterData): nodeType = Node.TEXT_NODE @@ -695,6 +696,8 @@ class Text(CharacterData): else: self.parentNode.insertBefore(newText, next) self.data = self.data[:offset] + self.nodeValue = self.data + self.length = len(self.data) return newText def writexml(self, writer, indent="", addindent="", newl=""): |