S
Steven Bethard
I was trying to get elementsoap_ working with just xml.etree from Python
2.5 (and no standalone elementtree installation). I think I got
everything working by changing the imports and copying in the
FancyTreeBuilder class (since only TreeBuilder and XMLTreeBuilder are in
the xml.etree.ElementTree module). I've attached the diff. Does this
seem like the right approach? I'd rather not have to install
elementtree alongside the one in the stdlib...
... _elementsoap: http://effbot.org/downloads/#elementsoap
STeVe
Only in elementsoap-0.3-20031123-stdlib\elementsoap: __init__.pyc
Only in elementsoap-0.3-20031123-stdlib\elementsoap: ElementGoogle.pyc
diff elementsoap-0.3-20031123\elementsoap/ElementSOAP.py elementsoap-0.3-20031123-stdlib\elementsoap/ElementSOAP.py
23,25c23,25
< from elementtree import ElementTree
< from elementtree import XMLTreeBuilder
< from elementtree.ElementTree import Element, QName, SubElement, tostring
---
< class NamespaceParser(XMLTreeBuilder.FancyTreeBuilder):
---
diff elementsoap-0.3-20031123\elementsoap/HTTPClient.py elementsoap-0.3-20031123-stdlib\elementsoap/HTTPClient.py
57c57
< from elementtree import ElementTree
---
2.5 (and no standalone elementtree installation). I think I got
everything working by changing the imports and copying in the
FancyTreeBuilder class (since only TreeBuilder and XMLTreeBuilder are in
the xml.etree.ElementTree module). I've attached the diff. Does this
seem like the right approach? I'd rather not have to install
elementtree alongside the one in the stdlib...
... _elementsoap: http://effbot.org/downloads/#elementsoap
STeVe
Only in elementsoap-0.3-20031123-stdlib\elementsoap: __init__.pyc
Only in elementsoap-0.3-20031123-stdlib\elementsoap: ElementGoogle.pyc
diff elementsoap-0.3-20031123\elementsoap/ElementSOAP.py elementsoap-0.3-20031123-stdlib\elementsoap/ElementSOAP.py
23,25c23,25
< from elementtree import ElementTree
< from elementtree import XMLTreeBuilder
< from elementtree.ElementTree import Element, QName, SubElement, tostring
---
264c314from xml.etree import ElementTree
from xml.etree.ElementTree import XMLTreeBuilder
from xml.etree.ElementTree import Element, QName, SubElement, tostring 260a261,310
# (experimental) An alternate builder that supports manipulation of
# new elements.
class FancyTreeBuilder(XMLTreeBuilder):
def __init__(self, html=0):
XMLTreeBuilder.__init__(self, html)
self._parser.StartNamespaceDeclHandler = self._start_ns
self._parser.EndNamespaceDeclHandler = self._end_ns
self.namespaces = []
def _start(self, tag, attrib_in):
elem = XMLTreeBuilder._start(self, tag, attrib_in)
self.start(elem)
def _start_list(self, tag, attrib_in):
elem = XMLTreeBuilder._start_list(self, tag, attrib_in)
self.start(elem)
def _end(self, tag):
elem = XMLTreeBuilder._end(self, tag)
self.end(elem)
def _start_ns(self, prefix, value):
self.namespaces.insert(0, (prefix, value))
def _end_ns(self, prefix):
assert self.namespaces.pop(0)[0] == prefix, "implementation confused"
##
# Hook method that's called when a new element has been opened.
# May access the <b>namespaces</b> attribute.
#
# @param element The new element. The tag name and attributes are,
# set, but it has no children, and the text and tail attributes
# are still empty.
def start(self, element):
pass
##
# Hook method that's called when a new element has been closed.
# May access the <b>namespaces</b> attribute.
#
# @param element The new element.
def end(self, element):
pass
##
< class NamespaceParser(XMLTreeBuilder.FancyTreeBuilder):
---
Only in elementsoap-0.3-20031123-stdlib\elementsoap: ElementSOAP.pycclass NamespaceParser(FancyTreeBuilder):
diff elementsoap-0.3-20031123\elementsoap/HTTPClient.py elementsoap-0.3-20031123-stdlib\elementsoap/HTTPClient.py
57c57
< from elementtree import ElementTree
---
Only in elementsoap-0.3-20031123-stdlib\elementsoap: HTTPClient.pycfrom xml.etree import ElementTree