[XML-SIG] minidom enhancements

Fred L. Drake, Jr. fdrake@acm.org
Mon, 15 Jul 2002 10:57:54 -0400


Uche Ogbuji writes:
 > And cause some problems  ;-)

That's why I asked people for feedback way back.  ;-)

 > It looks as if the class CharacterData no longer has an __init__.
 > Nor do the classes that derive from it.  This means that the usage
 > 
 > Text("spam")
 > Comment("eggs")
 > 
 > Now blows up.

Yes.  I discussed my reasoning for this when I originally proposed the
changes to minidom.

One of the driving complaints that caused me to dive back into minidom
was that Python's DOM was too slow.  Since the documented API for the
DOM uses factory methods on the Document instance (and using a factory
is far from "non-Pythonic"!), that had to be preserved.  Removing the
additional method call yields a nice performance improvement, but I
don't remember how much of the improvement was due specifically to
that change.  I did test it at the time, and the improvement was
substantial.

 > Which, I think is bad.  We construct nodes that way in 4Suite's minidom 
 > wrapper, and I can modify the cases, but I dislike the change.  I think it 
 > removes a very useful and Pythonic paradigm.  Also, who knows how much code it 
 > would break?  I know we've been guilty of changing APIs in 4Suite.  I guess 
 > I'm reaping my whirlwind  :-)
 > 
 > Is there a good reason for this, though?
 > 
 > Should we expect any more API surprises  ;-)

I don't think this is an API change (since the constructors are not
part of the API), nor do I think this should have been a surprise (I
specifically brought this up on the list).

I can certainly undo this particular part of the minidom changes if
others would like to make the class constructors part of the minidom
API.  I'm more interested in making it reasonable to use subclassing
to create extended DOM implementations.  I don't think restoring the
constructor signatures makes that easier (different, but not easier),
and subclass-based extended DOMs are inherently going beyond the DOM
API.  (Proxy-based extended DOMs are another matter.)


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation