[XML-SIG] pDomlette bug/non standard method?

Alan Kernnedy pyxml@xhaus.com
Mon, 24 Sep 2001 21:57:06 +0100


Mike Olson wrote:

> Alan, what version of 4Suite are you using?

Mike,

I'm using version 0.11.0, on both Python 2.0 and 2.1, and getting these results.
I ran this piece of code on both interpreters. The output follows.

<--code------------------------------------------------>
import sys
print "Python version is:", sys.version
print "PYTHONPATH is:", sys.path
import Ft.Lib.pDomlette
print "4Version is:", Ft.__version__
doc = "<doc>Some text</doc>"
domTree = Ft.Lib.pDomlette.PyExpatReader().fromString(doc)
textNode = domTree.documentElement.childNodes[0]
print "textNode.data = \"%s\"" % textNode.data
print "textNode.nodeValue = \"%s\"" % textNode.nodeValue
<--code------------------------------------------------>


Python 2.0 output -------------------------------------->
Python version is: 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)]
PYTHONPATH is: ['', 'c:\\temp', 'c:\\python20\\dlls', 'c:\\python20\\lib',
'c:\\python20\\lib\\plat-win', 'c:\\python20\\lib\\lib-tk', 'c:\\python20']
4Version is: 0.11.0
textNode.data = "Some text"
textNode.nodeValue = ""
Python 2.0 output -------------------------------------->

Python 2.1 output -------------------------------------->
Python version is: 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)]
PYTHONPATH is: ['', 'C:\\TEMP', 'C:\\python21\\DLLs', 'C:\\python21\\lib',
'C:\\python21\\lib\\plat-win', 'C:\\python21\\lib\\lib-tk', 'C:\\python21']
4Version is: 0.11.0
textNode.data = "Some text"
textNode.nodeValue = ""
Python 2.1 output -------------------------------------->

The reason why I checked paths is because the Python 2.0 installation had an old
4Suite 0.10.2 documentation directory. Although the doc directory remained
behind, I'm sure that the 0.11.0 installation wrote over the old 0.10.2 Ft.Lib
directory. I checked the two "pDomlette.py" files between the two different
0.11.0 installations, and there was no difference.

I was a little confused to see in the pDomlette.py file that there are only two
instances of the name "nodeValue", once setting it to an empty string in the
Node __init__ method, and once using it to index self.__dict__ in the
__setattr__ method of the Attribute class. With my limited knowledge of Python
class and object behind-the-scenes manipulation (and the performance costs
thereof), I expected to see use of the __getattr__ technique on the Node base
class, so that it would be inherited by every derived dom class.

Regards,

Alan.