Hi, >> > SOAPpy.Errors.HTTPError: <HTTPError 500 Internal Server Error> >> >> I guess the CGI must be updated to work with Squeeze's python. > > The problem is more general than that and, sadly, well known. The SOAP > interface needs to be ported to some (not so recent) structural change > to the way PTS webpages export data (see #539377 and friends).
I think this bug is different and is related to the fact that python-xml has been removed from Debian and is not in squeeze. So the way towards fixing this _particular_ issue seems to be, from what I understand, replacing the module xml.xpath (which does not exist anymore) usage with something. The attached patch seems to work on my squeeze box with my quick and dirty setup of the PTS SOAP interface. Watch for the extra python-lxml dependency. While I was at it, #539377, #540617 and #540675 all seem to be fixed. Alex
Index: bin/soap_lib.py =================================================================== --- bin/soap_lib.py (revision 2537) +++ bin/soap_lib.py (working copy) @@ -8,28 +8,26 @@ # (at your option) any later version. import os -import weakref -import xml -from xml import xpath -from xml.dom import minidom +from lxml import etree import config from common import hash_name -__dom = weakref.WeakValueDictionary() +__dom = {} def _dom(pkg): try: return __dom[pkg] except KeyError: html = os.path.join(config.webdir, hash_name(pkg), pkg) + ".html" if os.path.isfile(html): - doc = minidom.parse(html) + doc = etree.parse(html) __dom[pkg] = doc return doc def as_xpath(expr, pkg): - return xpath.Evaluate(expr, _dom(pkg)) + return _dom(pkg).xpath(expr, + namespaces={'xhtml': 'http://www.w3.org/1999/xhtml'}) def singleton(ret): if not ret: @@ -40,13 +38,7 @@ return ret def to_string(ret): - if isinstance(ret, xml.dom.minidom.Text): - s = str(ret.data) - elif isinstance(ret, xml.dom.minidom.Attr): - s = str(ret.nodeValue) - else: - s = str(ret) - return s + return unicode(ret).encode('utf-8') # SOAP messages are encoded in utf-8 def to_int(ret): if ret is None: Index: cgi-bin/soap-alpha.cgi =================================================================== --- cgi-bin/soap-alpha.cgi (revision 2537) +++ cgi-bin/soap-alpha.cgi (working copy) @@ -69,8 +69,8 @@ E.g.: C{{'stable': '1.2-4', 'testing': '1.5-6', 'unstable': '1.5-7'}} """ - nodes = as_xpath("//span[starts-with(@class,'srcversion')]/@title " - "| //span[starts-with(@class,'srcversion')]/child::text()", + nodes = as_xpath("//xhtml:span[starts-with(@class,'srcversion')]/@title " + "| //xhtml:span[starts-with(@class,'srcversion')]/child::text()", source) nodes.reverse() return dict_of_list(map(to_string, nodes)) @@ -85,7 +85,7 @@ @return: maintainer name """ nodes = as_xpath("//*[starts-with(@class,'maintainer')]" - "//*[starts-with(@class,'name')]/child::text()", source) + "//*[starts-with(@title,'maintainer')]/child::text()", source) return to_string(singleton(nodes)) def maintainer_email(source): @@ -97,10 +97,10 @@ @rtype: C{str} @return: maintainer email """ - nodes = as_xpath("//*[starts-with(@class,'maintainer')]" - "//*[starts-with(@class,'email')]/@href", source) + nodes = as_xpath("//*[starts-with(@class,'maintainer')]/xhtml:a/@href", + source) s = to_string(singleton(nodes)) - return s[7:] + return s.split('login=')[1] def maintainer(source): """ @@ -126,7 +126,8 @@ @rtype: C{list} of C{str} @return: uploader name list """ - nodes = as_xpath("//*[starts-with(@class,'uploaders')]" + nodes = as_xpath("//*[starts-with(@class,'maintainer')]" + "//*[starts-with(@class,'uploader')]" "//*[starts-with(@class,'name')]/child::text()", source) return to_strings(nodes) @@ -139,9 +140,10 @@ @rtype: C{list} of C{str} @return: uploader email list """ - nodes = as_xpath("//*[starts-with(@class,'uploaders')]" - "//*[starts-with(@class,'email')]/@href", source) - return map(lambda s: s[7:], to_strings(nodes)) + nodes = as_xpath("//*[starts-with(@class,'maintainer')]" + "//*[starts-with(@class,'uploader')]" + "//xhtml:a/@href", source) + return map(lambda s: s.split('login=')[1], to_strings(nodes)) def uploaders(source): """ @@ -182,7 +184,8 @@ @rtype: C{str} @return: package priority """ - return to_string(as_id('priority', source)) + nodes = as_xpath("//*[@id='priority']/xhtml:small/child::text()", source) + return to_string(singleton(nodes)) def section(source): """ @@ -193,7 +196,8 @@ @rtype: C{str} @return: package section """ - return to_string(as_id('section', source)) + nodes = as_xpath("//*[@id='section']/xhtml:small/child::text()", source) + return to_string(singleton(nodes)) def binary_names(source): """ @@ -204,7 +208,7 @@ @rtype: C{list} of C{str} @return: binary package names """ - nodes = as_xpath("//span[starts-with(@class,'binpkg')]//child::text()", + nodes = as_xpath("//xhtml:span[starts-with(@class,'binpkg')]//child::text()", source) return to_strings(nodes) @@ -246,8 +250,8 @@ - C{'help'}: bugs tagged C{help} I{(optional)} - C{'gift'}: bugs tagged C{gift} I{(optional)} """ - nodes = as_xpath("//span[starts-with(@class,'bugcount')]/@title " - "| //span[starts-with(@class,'bugcount')]/child::text()", + nodes = as_xpath("//xhtml:span[starts-with(@class,'bugcount')]/@title " + "| //xhtml:span[starts-with(@class,'bugcount')]/child::text()", source) nodes.reverse() return dict_of_list(map(to_string, nodes)) Index: README =================================================================== --- README (revision 2537) +++ README (working copy) @@ -15,7 +15,7 @@ - xsltproc - mhonarc - python -- python-xml +- python-lxml - devscripts (for uscan) - python-soappy (for SOAP access to the BTS) - python-debian