473,807 Members | 2,857 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

elementsoap with Python 2.5

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
FancyTreeBuilde r class (since only TreeBuilder and XMLTreeBuilder are in
the xml.etree.Eleme ntTree 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\elements oap: __init__.pyc
Only in elementsoap-0.3-20031123-stdlib\elements oap: ElementGoogle.p yc
diff elementsoap-0.3-20031123\elemen tsoap/ElementSOAP.py elementsoap-0.3-20031123-stdlib\elements oap/ElementSOAP.py
23,25c23,25
< from elementtree import ElementTree
< from elementtree import XMLTreeBuilder
< from elementtree.Ele mentTree import Element, QName, SubElement, tostring
---
from xml.etree import ElementTree
from xml.etree.Eleme ntTree import XMLTreeBuilder
from xml.etree.Eleme ntTree import Element, QName, SubElement, tostring
260a261,310
# (experimental) An alternate builder that supports manipulation of
# new elements.

class FancyTreeBuilde r(XMLTreeBuilde r):

def __init__(self, html=0):
XMLTreeBuilder. __init__(self, html)
self._parser.St artNamespaceDec lHandler = self._start_ns
self._parser.En dNamespaceDeclH andler = self._end_ns
self.namespaces = []

def _start(self, tag, attrib_in):
elem = XMLTreeBuilder. _start(self, tag, attrib_in)
self.start(elem )

def _start_list(sel f, tag, attrib_in):
elem = XMLTreeBuilder. _start_list(sel f, 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, "implementa tion confused"

##
# Hook method that's called when a new element has been opened.
# May access the <b>namespaces </battribute.
#
# @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 </battribute.
#
# @param element The new element.

def end(self, element):
pass

##
264c314
< class NamespaceParser (XMLTreeBuilder .FancyTreeBuild er):
---
class NamespaceParser (FancyTreeBuild er):
Only in elementsoap-0.3-20031123-stdlib\elements oap: ElementSOAP.pyc
diff elementsoap-0.3-20031123\elemen tsoap/HTTPClient.py elementsoap-0.3-20031123-stdlib\elements oap/HTTPClient.py
57c57
< from elementtree import ElementTree
---
from xml.etree import ElementTree
Only in elementsoap-0.3-20031123-stdlib\elements oap: HTTPClient.pyc

Oct 11 '06 #1
1 2165
Steven Bethard wrote:
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
FancyTreeBuilde r class (since only TreeBuilder and XMLTreeBuilder are in
the xml.etree.Eleme ntTree module). I've attached the diff. Does this
seem like the right approach?
the really correct approach would be to rewrite the code to use the
"iterparse" API instead.

FancyTreeBuilde r relies on various internals, but your copy-and-paste
fix should work just fine for Python 2.5 and/or ElementTree 1.2.

</F>

Oct 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2400
by: Emile van Sebille | last post by:
QOTW: "If we get 2.3.3c1 out in early December, we could release 2.3.3 final before the end of the year, and start 2004 with a 100% bug-free codebase <wink>." -- Tim Peters "cjOr proWe vbCould vbSettle prpFor noEnglish prpIn adjHungarian noNotation :-)" -- noPeter Jack Jensen reveals that python on mac continues as an osx option only starting with python2.4.
0
1899
by: Emile van Sebille | last post by:
QOTW: "Have you ever used the copy module? I am *not* a beginner, and have used it *once* (and I can't remember what for, either)." -- Michael Hudson "It will likely take a little practice before this stuff rattles off your fingertips easily." -- Paul Rubin BJ MacNevin wants to run python from a CD. http://groups.google.com/groups?threadm=BhVyb.389117$Tr4.1144562@attbi_s03
1
3254
by: mirandacascade | last post by:
Operating system: Windows XP Home Version of Python: 2.4 While looking through the tutorial on ElementSOAP at the following link: http://effbot.org/zone/element-soap.htm I observed sample code that included:
3
2528
by: mirandacascade | last post by:
1) Is it correct that none of the examples in the ElementSOAP tutorial: http://effbot.org/zone/elementsoap-1.htm include an example in which the SOAP message that contains the request includes a <soap:Headerblock? 2) If one wanted to make use of ElementSOAP, and one wanted it to produce a SOAP message that includes a <soap:Headerwould the general outline be:
0
9720
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9599
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3854
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.