1.1 --- a/PKG-INFO Sun Sep 14 02:30:58 2008 +0200
1.2 +++ b/PKG-INFO Sun Sep 14 22:55:59 2008 +0200
1.3 @@ -1,12 +1,12 @@
1.4 Metadata-Version: 1.1
1.5 Name: libxml2dom
1.6 -Version: 0.4.8
1.7 +Version: 0.5
1.8 Author: Paul Boddie
1.9 Author-email: paul at boddie org uk
1.10 Maintainer: Paul Boddie
1.11 Maintainer-email: paul at boddie org uk
1.12 Home-page: http://www.boddie.org.uk/python/libxml2dom.html
1.13 -Download-url: http://www.boddie.org.uk/python/downloads/libxml2dom-0.4.8.tar.gz
1.14 +Download-url: http://www.boddie.org.uk/python/downloads/libxml2dom-0.5.tar.gz
1.15 Summary: PyXML-style API for the libxml2 Python bindings
1.16 License: LGPL (version 3 or later)
1.17 Description: The libxml2dom package provides a traditional DOM wrapper around the Python
2.1 --- a/README.txt Sun Sep 14 02:30:58 2008 +0200
2.2 +++ b/README.txt Sun Sep 14 22:55:59 2008 +0200
2.3 @@ -73,7 +73,8 @@
2.4 * Changed some XML-RPC node properties in order to retain underlying DOM
2.5 properties such as data.
2.6 * Added convenience methods to the XML-RPC implementation, with combined
2.7 - node creation and insertion if requested.
2.8 + node creation and insertion if requested. Introduced similar conveniences
2.9 + into the SOAP implementation.
2.10 * Enabled prettyprinting support, finally.
2.11
2.12 New in libxml2dom 0.4.7 (Changes since libxml2dom 0.4.6)
3.1 --- a/libxml2dom/soap.py Sun Sep 14 02:30:58 2008 +0200
3.2 +++ b/libxml2dom/soap.py Sun Sep 14 22:55:59 2008 +0200
3.3 @@ -6,7 +6,7 @@
3.4
3.5 See: http://www.w3.org/TR/2007/REC-soap12-part0-20070427/
3.6
3.7 -Copyright (C) 2007 Paul Boddie <paul@boddie.org.uk>
3.8 +Copyright (C) 2007, 2008 Paul Boddie <paul@boddie.org.uk>
3.9
3.10 This program is free software; you can redistribute it and/or modify it under
3.11 the terms of the GNU Lesser General Public License as published by the Free
3.12 @@ -26,13 +26,14 @@
3.13 The sending and receiving of SOAP messages can be done using traditional HTTP
3.14 libraries.
3.15
3.16 -See tests/soap_test.py for more details.
3.17 +See tests/test_soap.py for more details.
3.18 """
3.19
3.20 import libxml2dom
3.21 from libxml2dom.macrolib import *
3.22 from libxml2dom.macrolib import \
3.23 createDocument as Node_createDocument
3.24 +from libxml2dom.values import ContentValue, SequenceValue
3.25
3.26 # SOAP-related namespaces.
3.27
3.28 @@ -59,68 +60,6 @@
3.29 "SOAP-ENC" : OLD_SOAP_ENCODING_NAMESPACE
3.30 }
3.31
3.32 -class SOAPImplementation(libxml2dom.Implementation):
3.33 -
3.34 - "Contains a SOAP-specific implementation."
3.35 -
3.36 - # Wrapping of documents.
3.37 -
3.38 - def adoptDocument(self, node):
3.39 - return SOAPDocument(node, self)
3.40 -
3.41 - # Factory functions.
3.42 -
3.43 - def get_node(self, _node, context_node):
3.44 -
3.45 - """
3.46 - Get a libxml2dom node for the given low-level '_node' and libxml2dom
3.47 - 'context_node'.
3.48 - """
3.49 -
3.50 - if Node_nodeType(_node) == context_node.ELEMENT_NODE:
3.51 -
3.52 - # Make special envelope elements.
3.53 -
3.54 - if Node_namespaceURI(_node) in (SOAP_ENVELOPE_NAMESPACE, OLD_SOAP_ENVELOPE_NAMESPACE):
3.55 - if Node_localName(_node) == "Envelope":
3.56 - return SOAPEnvelopeElement(_node, self, context_node.ownerDocument)
3.57 - elif Node_localName(_node) == "Header":
3.58 - return SOAPHeaderElement(_node, self, context_node.ownerDocument)
3.59 - elif Node_localName(_node) == "Body":
3.60 - return SOAPBodyElement(_node, self, context_node.ownerDocument)
3.61 - elif Node_localName(_node) == "Fault":
3.62 - return SOAPFaultElement(_node, self, context_node.ownerDocument)
3.63 - elif Node_localName(_node) == "Code":
3.64 - return SOAPCodeElement(_node, self, context_node.ownerDocument)
3.65 - elif Node_localName(_node) == "Subcode":
3.66 - return SOAPSubcodeElement(_node, self, context_node.ownerDocument)
3.67 - elif Node_localName(_node) == "Value":
3.68 - return SOAPValueElement(_node, self, context_node.ownerDocument)
3.69 - elif Node_localName(_node) == "Text":
3.70 - return SOAPTextElement(_node, self, context_node.ownerDocument)
3.71 -
3.72 - # Detect the method element.
3.73 -
3.74 - if Node_parentNode(_node) and Node_localName(Node_parentNode(_node)) == "Body" and \
3.75 - Node_namespaceURI(Node_parentNode(_node)) in (SOAP_ENVELOPE_NAMESPACE, OLD_SOAP_ENVELOPE_NAMESPACE):
3.76 -
3.77 - return SOAPMethodElement(_node, self, context_node.ownerDocument)
3.78 -
3.79 - # Otherwise, make generic SOAP elements.
3.80 -
3.81 - return SOAPElement(_node, self, context_node.ownerDocument)
3.82 -
3.83 - else:
3.84 - return libxml2dom.Implementation.get_node(self, _node, context_node)
3.85 -
3.86 - # Convenience functions.
3.87 -
3.88 - def createSOAPMessage(self, namespaceURI, localName):
3.89 -
3.90 - "Create a new SOAP message document (fragment)."
3.91 -
3.92 - return SOAPDocument(Node_createDocument(namespaceURI, localName, None), self).documentElement
3.93 -
3.94 # Node classes.
3.95
3.96 class SOAPNode(libxml2dom.Node):
3.97 @@ -140,33 +79,63 @@
3.98 ns.update(namespaces or {})
3.99 return libxml2dom.Node.xpath(self, expr, variables, ns)
3.100
3.101 - # All nodes support convenience methods.
3.102 + def add_or_replace_element(self, new_element):
3.103 +
3.104 + """
3.105 + Add or replace the given 'new_element', using its localName to find any
3.106 + element to be replaced.
3.107 + """
3.108 +
3.109 + elements = self.xpath(new_element.localName)
3.110 + if elements:
3.111 + self.replaceChild(new_element, elements[0])
3.112 + else:
3.113 + self.appendChild(new_element)
3.114 +
3.115 +class SOAPElement(ContentValue, SequenceValue, SOAPNode):
3.116 +
3.117 + "A SOAP element."
3.118
3.119 def convert(self, node):
3.120 return node.textContent.strip()
3.121
3.122 + def values(self):
3.123 + return [v.contents for v in self.xpath("*")]
3.124 +
3.125 def _contents(self):
3.126 # NOTE: Should check whether this should be a leaf element.
3.127 if not self.xpath("*"):
3.128 return (self.localName, getattr(self.ownerDocument, "convert", self.convert)(self))
3.129 else:
3.130 - return (self.localName, SOAPContents(self))
3.131 + return (self.localName, self)
3.132
3.133 def __len__(self):
3.134 - return 2
3.135 -
3.136 - def __getitem__(self, i):
3.137 - return self.contents[i]
3.138 + if not self.xpath("*"):
3.139 + return 2
3.140 + else:
3.141 + return SequenceValue.__len__(self)
3.142
3.143 def __eq__(self, other):
3.144 - if hasattr(other, "contents"):
3.145 - return self.contents == other.contents
3.146 + if not self.xpath("*"):
3.147 + return ContentValue.__eq__(self, other)
3.148 else:
3.149 - return self.contents == other
3.150 + return SequenceValue.__eq__(self, other)
3.151 +
3.152 + def __ne__(self, other):
3.153 + if not self.xpath("*"):
3.154 + return ContentValue.__ne__(self, other)
3.155 + else:
3.156 + return SequenceValue.__ne__(self, other)
3.157 +
3.158 + def __repr__(self):
3.159 + if self.contents[1] is self:
3.160 + return "<%s: %r>" % (self.__class__.__name__, self.values())
3.161 + else:
3.162 + return "<%s: %r>" % (self.__class__.__name__, self.contents)
3.163
3.164 # Node construction methods.
3.165
3.166 - def createSOAPElement(self, localName):
3.167 + def createSOAPElement(self, localName, insert=0):
3.168
3.169 "Create an element with the appropriate namespace and prefix."
3.170
3.171 @@ -176,61 +145,45 @@
3.172 name = prefix + ":" + localName
3.173 else:
3.174 name = localName
3.175 - return self.createElementNS(ref_element.namespaceURI, name)
3.176 + element = self.createElementNS(ref_element.namespaceURI, name)
3.177 + if insert:
3.178 + self.appendChild(element)
3.179 + return element
3.180
3.181 contents = property(_contents)
3.182
3.183 -class SOAPContents(object):
3.184 -
3.185 - "A wrapper around another node in order to provide sequence-like access."
3.186 -
3.187 - def __init__(self, node):
3.188 - self.node = node
3.189 -
3.190 - def __len__(self):
3.191 - return len(self.node.xpath("*"))
3.192 -
3.193 - def __getitem__(self, i):
3.194 - return self.node.xpath("*")[i]
3.195 -
3.196 - def __eq__(self, other):
3.197 - for i, j in map(None, self, other):
3.198 - if i != j:
3.199 - return False
3.200 - return True
3.201 -
3.202 class SOAPDocument(libxml2dom._Document, SOAPNode):
3.203
3.204 "A SOAP document fragment."
3.205
3.206 def _envelope(self):
3.207 - return self.xpath("env:Envelope|SOAP-ENV:Envelope")[0]
3.208 + return (self.xpath("env:Envelope|SOAP-ENV:Envelope") or [None])[0]
3.209
3.210 envelope = property(_envelope)
3.211
3.212 # Convenience methods and properties.
3.213
3.214 def _fault(self):
3.215 - return self.envelope.body.fault
3.216 + if self.envelope is not None:
3.217 + return self.envelope.fault
3.218 + else:
3.219 + return None
3.220
3.221 def _method(self):
3.222 - return self.envelope.body.method
3.223 + if self.envelope is not None:
3.224 + return self.envelope.method
3.225 + else:
3.226 + return None
3.227
3.228 fault = property(_fault)
3.229 method = property(_method)
3.230
3.231 -class SOAPElement(SOAPNode):
3.232 -
3.233 - "A SOAP element."
3.234 -
3.235 - pass
3.236 -
3.237 -class SOAPEnvelopeElement(SOAPNode):
3.238 +class SOAPEnvelopeElement(SOAPElement):
3.239
3.240 "A SOAP envelope element."
3.241
3.242 def _body(self):
3.243 - return self.xpath("env:Body|SOAP-ENV:Body")[0]
3.244 + return (self.xpath("env:Body|SOAP-ENV:Body") or [None])[0]
3.245
3.246 def _setBody(self, body):
3.247 self.appendChild(body)
3.248 @@ -238,18 +191,40 @@
3.249 def _delBody(self):
3.250 self.removeChild(self.body)
3.251
3.252 - def createBody(self):
3.253 - return self.createSOAPElement("Body")
3.254 + # Convenience methods and properties.
3.255 +
3.256 + def _fault(self):
3.257 + if self.body is not None:
3.258 + return self.body.fault
3.259 + else:
3.260 + return None
3.261 +
3.262 + def _method(self):
3.263 + if self.body is not None:
3.264 + return self.body.method
3.265 + else:
3.266 + return None
3.267 +
3.268 + fault = property(_fault)
3.269 + method = property(_method)
3.270 +
3.271 + # Node construction methods.
3.272 +
3.273 + def createBody(self, insert=0):
3.274 + element = self.createSOAPElement("Body")
3.275 + if insert:
3.276 + self.add_or_replace_element(element)
3.277 + return element
3.278
3.279 body = property(_body, _setBody, _delBody)
3.280
3.281 -class SOAPHeaderElement(SOAPNode):
3.282 +class SOAPHeaderElement(SOAPElement):
3.283
3.284 "A SOAP header element."
3.285
3.286 pass
3.287
3.288 -class SOAPBodyElement(SOAPNode):
3.289 +class SOAPBodyElement(SOAPElement):
3.290
3.291 "A SOAP body element."
3.292
3.293 @@ -264,13 +239,24 @@
3.294
3.295 # Node construction methods.
3.296
3.297 - def createFault(self):
3.298 - return self.createSOAPElement("Fault")
3.299 + def createMethod(self, namespaceURI, name, insert=0):
3.300 + if self.method is not None:
3.301 + self.removeChild(self.method)
3.302 + element = self.createElementNS(namespaceURI, name)
3.303 + element.setAttributeNS(SOAP_ENVELOPE_NAMESPACE, "env:encodingStyle", SOAP_ENCODING_NAMESPACE)
3.304 + self.appendChild(element)
3.305 + return element
3.306 +
3.307 + def createFault(self, insert=0):
3.308 + element = self.createSOAPElement("Fault")
3.309 + if insert:
3.310 + self.add_or_replace_element(element)
3.311 + return element
3.312
3.313 fault = property(_fault)
3.314 method = property(_method)
3.315
3.316 -class SOAPMethodElement(SOAPNode):
3.317 +class SOAPMethodElement(SOAPElement):
3.318
3.319 "A SOAP method element."
3.320
3.321 @@ -291,15 +277,22 @@
3.322 else:
3.323 return None
3.324
3.325 + def _parameters(self):
3.326 + return self.xpath("*")
3.327 +
3.328 def _parameterValues(self):
3.329 - return [value.contents for value in self.xpath("*")]
3.330 + return self.values()
3.331 +
3.332 + def __repr__(self):
3.333 + return "<SOAPMethodElement: %r>" % self.parameters
3.334
3.335 methodName = property(_methodName)
3.336 resultParameter = property(_resultParameter)
3.337 resultParameterValue = property(_resultParameterValue)
3.338 parameterValues = property(_parameterValues)
3.339 + parameters = property(_parameters)
3.340
3.341 -class SOAPFaultElement(SOAPNode):
3.342 +class SOAPFaultElement(SOAPElement):
3.343
3.344 "A SOAP fault element."
3.345
3.346 @@ -323,15 +316,20 @@
3.347 def _detail(self):
3.348 return (self.xpath("env:Detail|SOAP-ENV:Detail") or [None])[0]
3.349
3.350 - def createCode(self):
3.351 - return self.createSOAPElement("Code")
3.352 + # Node construction methods.
3.353 +
3.354 + def createCode(self, insert=0):
3.355 + element = self.createSOAPElement("Code")
3.356 + if insert:
3.357 + self.add_or_replace_element(element)
3.358 + return element
3.359
3.360 code = property(_code)
3.361 subcode = property(_subcode)
3.362 reason = property(_reason)
3.363 detail = property(_detail)
3.364
3.365 -class SOAPSubcodeElement(SOAPNode):
3.366 +class SOAPSubcodeElement(SOAPElement):
3.367
3.368 "A SOAP subcode element."
3.369
3.370 @@ -351,10 +349,14 @@
3.371 self.appendChild(v)
3.372 v.value = value
3.373
3.374 - def createValue(self, value=None):
3.375 + # Node construction methods.
3.376 +
3.377 + def createValue(self, value=None, insert=0):
3.378 code_value = self.createSOAPElement("Value")
3.379 if value is not None:
3.380 code_value.value = code
3.381 + if insert:
3.382 + self.add_or_replace_element(code_value)
3.383 return code_value
3.384
3.385 value = property(_value, _setValue)
3.386 @@ -366,12 +368,17 @@
3.387 def _subcode(self):
3.388 return (self.xpath("env:Subcode|SOAP-ENV:Subcode") or [None])[0]
3.389
3.390 - def createSubcode(self):
3.391 - return self.createSOAPElement("Subcode")
3.392 + # Node construction methods.
3.393 +
3.394 + def createSubcode(self, insert=0):
3.395 + element = self.createSOAPElement("Subcode")
3.396 + if insert:
3.397 + self.add_or_replace_element(element)
3.398 + return element
3.399
3.400 subcode = property(_subcode)
3.401
3.402 -class SOAPValueElement(SOAPNode):
3.403 +class SOAPValueElement(SOAPElement):
3.404
3.405 "A SOAP value element."
3.406
3.407 @@ -398,13 +405,76 @@
3.408
3.409 lang = property(_lang, _setLang)
3.410
3.411 +# Implementation-related functionality.
3.412 +
3.413 +class SOAPImplementation(libxml2dom.Implementation):
3.414 +
3.415 + "Contains a SOAP-specific implementation."
3.416 +
3.417 + # Mapping of element names to wrappers.
3.418 +
3.419 + _class_for_name = {
3.420 + "Envelope" : SOAPEnvelopeElement,
3.421 + "Header" : SOAPHeaderElement,
3.422 + "Body" : SOAPBodyElement,
3.423 + "Fault" : SOAPFaultElement,
3.424 + "Code" : SOAPCodeElement,
3.425 + "Subcode" : SOAPSubcodeElement,
3.426 + "Value" : SOAPValueElement,
3.427 + "Text" : SOAPTextElement
3.428 + }
3.429 +
3.430 + # Wrapping of documents.
3.431 +
3.432 + def adoptDocument(self, node):
3.433 + return SOAPDocument(node, self)
3.434 +
3.435 + # Factory functions.
3.436 +
3.437 + def get_node(self, _node, context_node):
3.438 +
3.439 + """
3.440 + Get a libxml2dom node for the given low-level '_node' and libxml2dom
3.441 + 'context_node'.
3.442 + """
3.443 +
3.444 + if Node_nodeType(_node) == context_node.ELEMENT_NODE:
3.445 +
3.446 + # Make special envelope elements.
3.447 +
3.448 + if Node_namespaceURI(_node) in (SOAP_ENVELOPE_NAMESPACE, OLD_SOAP_ENVELOPE_NAMESPACE):
3.449 + cls = self._class_for_name[Node_localName(_node)]
3.450 + return cls(_node, self, context_node.ownerDocument)
3.451 +
3.452 + # Detect the method element.
3.453 +
3.454 + if Node_parentNode(_node) and Node_localName(Node_parentNode(_node)) == "Body" and \
3.455 + Node_namespaceURI(Node_parentNode(_node)) in (SOAP_ENVELOPE_NAMESPACE, OLD_SOAP_ENVELOPE_NAMESPACE):
3.456 +
3.457 + return SOAPMethodElement(_node, self, context_node.ownerDocument)
3.458 +
3.459 + # Otherwise, make generic SOAP elements.
3.460 +
3.461 + return SOAPElement(_node, self, context_node.ownerDocument)
3.462 +
3.463 + else:
3.464 + return libxml2dom.Implementation.get_node(self, _node, context_node)
3.465 +
3.466 + # Convenience functions.
3.467 +
3.468 + def createSOAPMessage(self):
3.469 +
3.470 + "Create a new SOAP message document (fragment)."
3.471 +
3.472 + return SOAPDocument(Node_createDocument(SOAP_ENVELOPE_NAMESPACE, "env:Envelope", None), self).documentElement
3.473 +
3.474 # Utility functions.
3.475
3.476 createDocument = libxml2dom.createDocument
3.477 createDocumentType = libxml2dom.createDocumentType
3.478
3.479 -def createSOAPMessage(namespaceURI, localName):
3.480 - return default_impl.createSOAPMessage(namespaceURI, localName)
3.481 +def createSOAPMessage():
3.482 + return default_impl.createSOAPMessage()
3.483
3.484 def parse(stream_or_string, html=0, htmlencoding=None, unfinished=0, impl=None):
3.485 return libxml2dom.parse(stream_or_string, html=html, htmlencoding=htmlencoding, unfinished=unfinished, impl=(impl or default_impl))
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/libxml2dom/values.py Sun Sep 14 22:55:59 2008 +0200
4.3 @@ -0,0 +1,59 @@
4.4 +#!/usr/bin/env python
4.5 +
4.6 +"""
4.7 +Python value emulation.
4.8 +
4.9 +Copyright (C) 2008 Paul Boddie <paul@boddie.org.uk>
4.10 +
4.11 +This program is free software; you can redistribute it and/or modify it under
4.12 +the terms of the GNU Lesser General Public License as published by the Free
4.13 +Software Foundation; either version 3 of the License, or (at your option) any
4.14 +later version.
4.15 +
4.16 +This program is distributed in the hope that it will be useful, but WITHOUT
4.17 +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
4.18 +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
4.19 +details.
4.20 +
4.21 +You should have received a copy of the GNU Lesser General Public License along
4.22 +with this program. If not, see <http://www.gnu.org/licenses/>.
4.23 +"""
4.24 +
4.25 +class ContentValue:
4.26 +
4.27 + """
4.28 + Equality support for nodes having contents which should have some
4.29 + interoperability with normal Python objects.
4.30 + """
4.31 +
4.32 + def __eq__(self, other):
4.33 + if hasattr(other, "contents"):
4.34 + return self.contents == other.contents
4.35 + else:
4.36 + return self.contents == other
4.37 +
4.38 + def __ne__(self, other):
4.39 + return not self.__eq__(other)
4.40 +
4.41 +class SequenceValue:
4.42 +
4.43 + """
4.44 + Equality and access support for nodes having sequence-like contents.
4.45 + """
4.46 +
4.47 + def __eq__(self, other):
4.48 + for i, j in map(None, self, other):
4.49 + if i != j:
4.50 + return False
4.51 + return True
4.52 +
4.53 + def __ne__(self, other):
4.54 + return not self.__eq__(other)
4.55 +
4.56 + def __len__(self):
4.57 + return len(self.values())
4.58 +
4.59 + def __getitem__(self, i):
4.60 + return self.values()[i]
4.61 +
4.62 +# vim: tabstop=4 expandtab shiftwidth=4
5.1 --- a/libxml2dom/xmlrpc.py Sun Sep 14 02:30:58 2008 +0200
5.2 +++ b/libxml2dom/xmlrpc.py Sun Sep 14 22:55:59 2008 +0200
5.3 @@ -40,6 +40,7 @@
5.4 createDocument as Node_createDocument
5.5 import datetime
5.6 import xml.dom
5.7 +from libxml2dom.values import ContentValue, SequenceValue
5.8
5.9 # Node classes.
5.10
5.11 @@ -88,38 +89,6 @@
5.12 else:
5.13 raise ValueError, "Value %r cannot be serialised." % value
5.14
5.15 -class ContentEquality:
5.16 -
5.17 - "Equality testing."
5.18 -
5.19 - def __eq__(self, other):
5.20 - if hasattr(other, "contents"):
5.21 - return self.contents == other.contents
5.22 - else:
5.23 - return self.contents == other
5.24 -
5.25 - def __ne__(self, other):
5.26 - return not self.__eq__(other)
5.27 -
5.28 -class SequenceEquality:
5.29 -
5.30 - "Sequence equality testing."
5.31 -
5.32 - def __eq__(self, other):
5.33 - for i, j in map(None, self, other):
5.34 - if i != j:
5.35 - return False
5.36 - return True
5.37 -
5.38 - def __ne__(self, other):
5.39 - return not self.__eq__(other)
5.40 -
5.41 - def __len__(self):
5.42 - return len(self.values())
5.43 -
5.44 - def __getitem__(self, i):
5.45 - return self.values()[i]
5.46 -
5.47 class XMLRPCElement(XMLRPCNode):
5.48
5.49 "An XML-RPC element."
5.50 @@ -227,7 +196,7 @@
5.51 parameterValues = property(_parameterValues, _setParameterValues)
5.52 parameters = property(_parameters)
5.53
5.54 -class XMLRPCParametersElement(SequenceEquality, XMLRPCNode):
5.55 +class XMLRPCParametersElement(SequenceValue, XMLRPCNode):
5.56
5.57 """
5.58 An XML-RPC parameters/params element.
5.59 @@ -264,7 +233,7 @@
5.60
5.61 parameters = property(_parameters)
5.62
5.63 -class XMLRPCParameterElement(ContentEquality, XMLRPCNode):
5.64 +class XMLRPCParameterElement(ContentValue, XMLRPCNode):
5.65
5.66 """
5.67 An XML-RPC parameter/param element.
5.68 @@ -322,7 +291,7 @@
5.69 valueElement = property(_valueElement)
5.70 contents = property(_contents)
5.71
5.72 -class XMLRPCArrayElement(SequenceEquality, XMLRPCNode):
5.73 +class XMLRPCArrayElement(SequenceValue, XMLRPCNode):
5.74
5.75 """
5.76 An XML-RPC array element.
5.77 @@ -361,7 +330,7 @@
5.78 dataElement = property(_dataElement)
5.79 contents = property(_contents)
5.80
5.81 -class XMLRPCStructElement(SequenceEquality, XMLRPCNode):
5.82 +class XMLRPCStructElement(SequenceValue, XMLRPCNode):
5.83
5.84 """
5.85 An XML-RPC structure element.
5.86 @@ -415,7 +384,7 @@
5.87 members = property(_members)
5.88 contents = property(_contents)
5.89
5.90 -class XMLRPCDataElement(SequenceEquality, XMLRPCNode):
5.91 +class XMLRPCDataElement(SequenceValue, XMLRPCNode):
5.92
5.93 """
5.94 An XML-RPC array data element.
5.95 @@ -522,7 +491,7 @@
5.96 valueElement = property(_valueElement)
5.97 contents = property(_contents)
5.98
5.99 -class XMLRPCStringElement(ContentEquality, XMLRPCNode):
5.100 +class XMLRPCStringElement(ContentValue, XMLRPCNode):
5.101
5.102 "An XML-RPC string element."
5.103
6.1 --- a/packages/debian-etch/python-libxml2dom/debian/changelog Sun Sep 14 02:30:58 2008 +0200
6.2 +++ b/packages/debian-etch/python-libxml2dom/debian/changelog Sun Sep 14 22:55:59 2008 +0200
6.3 @@ -1,6 +1,12 @@
6.4 -libxml2dom (0.4.8-0ubuntu1) stable; urgency=low
6.5 +libxml2dom (0.5-0ubuntu1) stable; urgency=low
6.6
6.7 - * Added more XML-RPC convenience methods and properties.
6.8 + * Changed some XML-RPC node properties in order to retain
6.9 + underlying DOM properties such as data.
6.10 + * Added convenience methods to the XML-RPC implementation,
6.11 + with combined node creation and insertion if requested.
6.12 + Introduced similar conveniences into the SOAP
6.13 + implementation.
6.14 + * Enabled prettyprinting support, finally.
6.15
6.16 -- Paul Boddie <paul@boddie.org.uk> Wed, 10 Sep 2008 00:31:55 +0200
6.17
7.1 --- a/packages/debian-sarge/python2.3-libxml2dom/debian/changelog Sun Sep 14 02:30:58 2008 +0200
7.2 +++ b/packages/debian-sarge/python2.3-libxml2dom/debian/changelog Sun Sep 14 22:55:59 2008 +0200
7.3 @@ -1,6 +1,12 @@
7.4 -libxml2dom (0.4.8-0ubuntu1) stable; urgency=low
7.5 +libxml2dom (0.5-0ubuntu1) stable; urgency=low
7.6
7.7 - * Added more XML-RPC convenience methods and properties.
7.8 + * Changed some XML-RPC node properties in order to retain
7.9 + underlying DOM properties such as data.
7.10 + * Added convenience methods to the XML-RPC implementation,
7.11 + with combined node creation and insertion if requested.
7.12 + Introduced similar conveniences into the SOAP
7.13 + implementation.
7.14 + * Enabled prettyprinting support, finally.
7.15
7.16 -- Paul Boddie <paul@boddie.org.uk> Wed, 10 Sep 2008 00:32:39 +0200
7.17
8.1 --- a/packages/ubuntu-feisty/python-libxml2dom/debian/changelog Sun Sep 14 02:30:58 2008 +0200
8.2 +++ b/packages/ubuntu-feisty/python-libxml2dom/debian/changelog Sun Sep 14 22:55:59 2008 +0200
8.3 @@ -1,6 +1,12 @@
8.4 -libxml2dom (0.4.8-0ubuntu1) feisty; urgency=low
8.5 +libxml2dom (0.5-0ubuntu1) feisty; urgency=low
8.6
8.7 - * Added more XML-RPC convenience methods and properties.
8.8 + * Changed some XML-RPC node properties in order to retain
8.9 + underlying DOM properties such as data.
8.10 + * Added convenience methods to the XML-RPC implementation,
8.11 + with combined node creation and insertion if requested.
8.12 + Introduced similar conveniences into the SOAP
8.13 + implementation.
8.14 + * Enabled prettyprinting support, finally.
8.15
8.16 -- Paul Boddie <paul@boddie.org.uk> Wed, 10 Sep 2008 00:33:14 +0200
8.17
9.1 --- a/packages/ubuntu-hoary/python2.4-libxml2dom/debian/changelog Sun Sep 14 02:30:58 2008 +0200
9.2 +++ b/packages/ubuntu-hoary/python2.4-libxml2dom/debian/changelog Sun Sep 14 22:55:59 2008 +0200
9.3 @@ -1,6 +1,12 @@
9.4 -libxml2dom (0.4.8-0ubuntu1) hoary; urgency=low
9.5 +libxml2dom (0.5-0ubuntu1) hoary; urgency=low
9.6
9.7 - * Added more XML-RPC convenience methods and properties.
9.8 + * Changed some XML-RPC node properties in order to retain
9.9 + underlying DOM properties such as data.
9.10 + * Added convenience methods to the XML-RPC implementation,
9.11 + with combined node creation and insertion if requested.
9.12 + Introduced similar conveniences into the SOAP
9.13 + implementation.
9.14 + * Enabled prettyprinting support, finally.
9.15
9.16 -- Paul Boddie <paul@boddie.org.uk> Wed, 10 Sep 2008 00:32:59 +0200
9.17
10.1 --- a/tests/soap_test.py Sun Sep 14 02:30:58 2008 +0200
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,145 +0,0 @@
10.4 -#!/usr/bin/env python
10.5 -# -*- coding: iso-8859-15 -*-
10.6 -
10.7 -import libxml2dom.soap
10.8 -
10.9 -request = """<?xml version='1.0' encoding='iso-8859-1'?>
10.10 -<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" >
10.11 - <env:Header>
10.12 - <t:transaction
10.13 - xmlns:t="http://thirdparty.example.org/transaction"
10.14 - env:encodingStyle="http://example.com/encoding"
10.15 - env:mustUnderstand="true" >5</t:transaction>
10.16 - </env:Header>
10.17 - <env:Body>
10.18 - <m:chargeReservation
10.19 - env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
10.20 - xmlns:m="http://travelcompany.example.org/">
10.21 - <m:reservation xmlns:m="http://travelcompany.example.org/reservation">
10.22 - <m:code>FT35ZBQ</m:code>
10.23 - </m:reservation>
10.24 - <o:creditCard xmlns:o="http://mycompany.example.com/financial">
10.25 - <n:name xmlns:n="http://mycompany.example.com/employees">
10.26 - Ĺke Jógvan Řyvind
10.27 - </n:name>
10.28 - <o:number>123456789099999</o:number>
10.29 - <o:expiration>2005-02</o:expiration>
10.30 - </o:creditCard>
10.31 - </m:chargeReservation>
10.32 - </env:Body>
10.33 -</env:Envelope>"""
10.34 -
10.35 -req = libxml2dom.soap.parseString(request)
10.36 -assert req.method.methodName == "chargeReservation"
10.37 -assert req.method.parameterValues == [
10.38 - ("reservation", [("code", "FT35ZBQ")]),
10.39 - ("creditCard", [("name", u"Ĺke Jógvan Řyvind"),
10.40 - ("number", "123456789099999"),
10.41 - ("expiration", "2005-02")
10.42 - ])
10.43 - ]
10.44 -assert req.fault is None
10.45 -print "Method name:", req.method.methodName
10.46 -print "Parameter values:", req.method.parameterValues
10.47 -print "Fault:", req.fault
10.48 -
10.49 -response = """<?xml version='1.0' encoding='iso-8859-1'?>
10.50 -<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" >
10.51 - <env:Header>
10.52 - <t:transaction
10.53 - xmlns:t="http://thirdparty.example.org/transaction"
10.54 - env:encodingStyle="http://example.com/encoding"
10.55 - env:mustUnderstand="true">5</t:transaction>
10.56 - </env:Header>
10.57 - <env:Body>
10.58 - <m:chargeReservationResponse
10.59 - env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
10.60 - xmlns:m="http://travelcompany.example.org/">
10.61 - <m:code>FT35ZBQ</m:code>
10.62 - <m:viewAt>
10.63 - http://travelcompany.example.org/reservations?code=FT35ZBQ
10.64 - </m:viewAt>
10.65 - </m:chargeReservationResponse>
10.66 - </env:Body>
10.67 -</env:Envelope>"""
10.68 -
10.69 -resp = libxml2dom.soap.parseString(response)
10.70 -assert resp.method.methodName == "chargeReservationResponse"
10.71 -assert resp.method.parameterValues == [
10.72 - ("code", "FT35ZBQ"),
10.73 - ("viewAt", "http://travelcompany.example.org/reservations?code=FT35ZBQ")
10.74 - ]
10.75 -assert resp.fault is None
10.76 -print "Method name:", resp.method.methodName
10.77 -print "Parameter values:", resp.method.parameterValues
10.78 -print "Fault:", resp.fault
10.79 -
10.80 -response2 = """<?xml version='1.0' encoding='iso-8859-1'?>
10.81 -<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" >
10.82 - <env:Header>
10.83 - <t:transaction
10.84 - xmlns:t="http://thirdparty.example.org/transaction"
10.85 - env:encodingStyle="http://example.com/encoding"
10.86 - env:mustUnderstand="true">5</t:transaction>
10.87 - </env:Header>
10.88 - <env:Body>
10.89 - <m:chargeReservationResponse
10.90 - env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
10.91 - xmlns:rpc="http://www.w3.org/2003/05/soap-rpc"
10.92 - xmlns:m="http://travelcompany.example.org/">
10.93 - <rpc:result>m:status</rpc:result>
10.94 - <m:status>confirmed</m:status>
10.95 - <m:code>FT35ZBQ</m:code>
10.96 - <m:viewAt>
10.97 - http://travelcompany.example.org/reservations?code=FT35ZBQ
10.98 - </m:viewAt>
10.99 - </m:chargeReservationResponse>
10.100 - </env:Body>
10.101 -</env:Envelope>"""
10.102 -
10.103 -resp2 = libxml2dom.soap.parseString(response2)
10.104 -assert resp2.method.methodName == "chargeReservationResponse"
10.105 -assert resp2.method.parameterValues == [
10.106 - ("result", "m:status"),
10.107 - ("status", "confirmed"),
10.108 - ("code", "FT35ZBQ"),
10.109 - ("viewAt", "http://travelcompany.example.org/reservations?code=FT35ZBQ")
10.110 - ]
10.111 -assert resp2.fault is None
10.112 -print "Method name:", resp2.method.methodName
10.113 -print "Parameter values:", resp2.method.parameterValues
10.114 -print "Fault:", resp2.fault
10.115 -
10.116 -failed = """<?xml version='1.0' encoding='iso-8859-1'?>
10.117 -<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
10.118 - xmlns:rpc='http://www.w3.org/2003/05/soap-rpc'>
10.119 - <env:Body>
10.120 - <env:Fault>
10.121 - <env:Code>
10.122 - <env:Value>env:Sender</env:Value>
10.123 - <env:Subcode>
10.124 - <env:Value>rpc:BadArguments</env:Value>
10.125 - </env:Subcode>
10.126 - </env:Code>
10.127 - <env:Reason>
10.128 - <env:Text xml:lang="en-US">Processing error</env:Text>
10.129 - <env:Text xml:lang="cs">Chyba zpracování</env:Text>
10.130 - </env:Reason>
10.131 - <env:Detail>
10.132 - <e:myFaultDetails
10.133 - xmlns:e="http://travelcompany.example.org/faults">
10.134 - <e:message>Name does not match card number</e:message>
10.135 - <e:errorcode>999</e:errorcode>
10.136 - </e:myFaultDetails>
10.137 - </env:Detail>
10.138 - </env:Fault>
10.139 - </env:Body>
10.140 -</env:Envelope>"""
10.141 -
10.142 -f = libxml2dom.soap.parseString(failed)
10.143 -assert f.method is None
10.144 -assert f.fault.code == "env:Sender"
10.145 -assert f.fault.subcode == "rpc:BadArguments"
10.146 -print "Fault code:", f.fault.code
10.147 -
10.148 -# vim: tabstop=4 expandtab shiftwidth=4
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/tests/test_soap.py Sun Sep 14 22:55:59 2008 +0200
11.3 @@ -0,0 +1,162 @@
11.4 +#!/usr/bin/env python
11.5 +# -*- coding: iso-8859-15 -*-
11.6 +
11.7 +import libxml2dom.soap
11.8 +
11.9 +request = """<?xml version='1.0' encoding='iso-8859-1'?>
11.10 +<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" >
11.11 + <env:Header>
11.12 + <t:transaction
11.13 + xmlns:t="http://thirdparty.example.org/transaction"
11.14 + env:encodingStyle="http://example.com/encoding"
11.15 + env:mustUnderstand="true" >5</t:transaction>
11.16 + </env:Header>
11.17 + <env:Body>
11.18 + <m:chargeReservation
11.19 + env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
11.20 + xmlns:m="http://travelcompany.example.org/">
11.21 + <m:reservation xmlns:m="http://travelcompany.example.org/reservation">
11.22 + <m:code>FT35ZBQ</m:code>
11.23 + </m:reservation>
11.24 + <o:creditCard xmlns:o="http://mycompany.example.com/financial">
11.25 + <n:name xmlns:n="http://mycompany.example.com/employees">
11.26 + Ĺke Jógvan Řyvind
11.27 + </n:name>
11.28 + <o:number>123456789099999</o:number>
11.29 + <o:expiration>2005-02</o:expiration>
11.30 + </o:creditCard>
11.31 + </m:chargeReservation>
11.32 + </env:Body>
11.33 +</env:Envelope>"""
11.34 +
11.35 +req = libxml2dom.soap.parseString(request)
11.36 +print "Method name:", req.method.methodName
11.37 +print "Parameter values:", req.method.parameterValues
11.38 +print "Fault:", req.fault
11.39 +print
11.40 +assert req.method.methodName == "chargeReservation"
11.41 +assert req.method.parameterValues == [
11.42 + ("reservation", [("code", "FT35ZBQ")]),
11.43 + ("creditCard", [("name", u"Ĺke Jógvan Řyvind"),
11.44 + ("number", "123456789099999"),
11.45 + ("expiration", "2005-02")
11.46 + ])
11.47 + ]
11.48 +assert req.fault is None
11.49 +
11.50 +response = """<?xml version='1.0' encoding='iso-8859-1'?>
11.51 +<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" >
11.52 + <env:Header>
11.53 + <t:transaction
11.54 + xmlns:t="http://thirdparty.example.org/transaction"
11.55 + env:encodingStyle="http://example.com/encoding"
11.56 + env:mustUnderstand="true">5</t:transaction>
11.57 + </env:Header>
11.58 + <env:Body>
11.59 + <m:chargeReservationResponse
11.60 + env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
11.61 + xmlns:m="http://travelcompany.example.org/">
11.62 + <m:code>FT35ZBQ</m:code>
11.63 + <m:viewAt>
11.64 + http://travelcompany.example.org/reservations?code=FT35ZBQ
11.65 + </m:viewAt>
11.66 + </m:chargeReservationResponse>
11.67 + </env:Body>
11.68 +</env:Envelope>"""
11.69 +
11.70 +resp = libxml2dom.soap.parseString(response)
11.71 +print "Method name:", resp.method.methodName
11.72 +print "Parameter values:", resp.method.parameterValues
11.73 +print "Fault:", resp.fault
11.74 +print
11.75 +print "Request parameters vs. response parameters:"
11.76 +print req.method.parameters[0][0], resp.method.parameters[0]
11.77 +print
11.78 +assert resp.method.methodName == "chargeReservationResponse"
11.79 +assert resp.method.parameterValues == [
11.80 + ("code", "FT35ZBQ"),
11.81 + ("viewAt", "http://travelcompany.example.org/reservations?code=FT35ZBQ")
11.82 + ]
11.83 +assert resp.fault is None
11.84 +assert req.method.parameters[0][0] == resp.method.parameters[0]
11.85 +
11.86 +response2 = """<?xml version='1.0' encoding='iso-8859-1'?>
11.87 +<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" >
11.88 + <env:Header>
11.89 + <t:transaction
11.90 + xmlns:t="http://thirdparty.example.org/transaction"
11.91 + env:encodingStyle="http://example.com/encoding"
11.92 + env:mustUnderstand="true">5</t:transaction>
11.93 + </env:Header>
11.94 + <env:Body>
11.95 + <m:chargeReservationResponse
11.96 + env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
11.97 + xmlns:rpc="http://www.w3.org/2003/05/soap-rpc"
11.98 + xmlns:m="http://travelcompany.example.org/">
11.99 + <rpc:result>m:status</rpc:result>
11.100 + <m:status>confirmed</m:status>
11.101 + <m:code>FT35ZBQ</m:code>
11.102 + <m:viewAt>
11.103 + http://travelcompany.example.org/reservations?code=FT35ZBQ
11.104 + </m:viewAt>
11.105 + </m:chargeReservationResponse>
11.106 + </env:Body>
11.107 +</env:Envelope>"""
11.108 +
11.109 +resp2 = libxml2dom.soap.parseString(response2)
11.110 +print "Method name:", resp2.method.methodName
11.111 +print "Parameter values:", resp2.method.parameterValues
11.112 +print "Fault:", resp2.fault
11.113 +print
11.114 +print "Request parameters vs. response parameters:"
11.115 +print req.method.parameters[0][0], resp2.method.parameters[2]
11.116 +print
11.117 +print "Response parameters:"
11.118 +print resp.method.parameters[0], resp2.method.parameters[2]
11.119 +print resp.method.parameters[1], resp2.method.parameters[3]
11.120 +print
11.121 +assert resp2.method.methodName == "chargeReservationResponse"
11.122 +assert resp2.method.parameterValues == [
11.123 + ("result", "m:status"),
11.124 + ("status", "confirmed"),
11.125 + ("code", "FT35ZBQ"),
11.126 + ("viewAt", "http://travelcompany.example.org/reservations?code=FT35ZBQ")
11.127 + ]
11.128 +assert resp2.fault is None
11.129 +assert req.method.parameters[0][0] == resp2.method.parameters[2]
11.130 +assert resp.method.parameters[0] == resp2.method.parameters[2]
11.131 +assert resp.method.parameters[1] == resp2.method.parameters[3]
11.132 +
11.133 +failed = """<?xml version='1.0' encoding='iso-8859-1'?>
11.134 +<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
11.135 + xmlns:rpc='http://www.w3.org/2003/05/soap-rpc'>
11.136 + <env:Body>
11.137 + <env:Fault>
11.138 + <env:Code>
11.139 + <env:Value>env:Sender</env:Value>
11.140 + <env:Subcode>
11.141 + <env:Value>rpc:BadArguments</env:Value>
11.142 + </env:Subcode>
11.143 + </env:Code>
11.144 + <env:Reason>
11.145 + <env:Text xml:lang="en-US">Processing error</env:Text>
11.146 + <env:Text xml:lang="cs">Chyba zpracování</env:Text>
11.147 + </env:Reason>
11.148 + <env:Detail>
11.149 + <e:myFaultDetails
11.150 + xmlns:e="http://travelcompany.example.org/faults">
11.151 + <e:message>Name does not match card number</e:message>
11.152 + <e:errorcode>999</e:errorcode>
11.153 + </e:myFaultDetails>
11.154 + </env:Detail>
11.155 + </env:Fault>
11.156 + </env:Body>
11.157 +</env:Envelope>"""
11.158 +
11.159 +f = libxml2dom.soap.parseString(failed)
11.160 +print "Fault code:", f.fault.code
11.161 +assert f.method is None
11.162 +assert f.fault.code == "env:Sender"
11.163 +assert f.fault.subcode == "rpc:BadArguments"
11.164 +
11.165 +# vim: tabstop=4 expandtab shiftwidth=4