paulb@304 | 1 | #!/usr/bin/env python |
paulb@304 | 2 | |
paulb@304 | 3 | """ |
paulb@304 | 4 | XML-RPC support using libxml2dom. |
paulb@304 | 5 | |
paulb@304 | 6 | See: http://www.xmlrpc.com/spec |
paulb@304 | 7 | |
paulb@304 | 8 | Copyright (C) 2007 Paul Boddie <paul@boddie.org.uk> |
paulb@304 | 9 | |
paulb@304 | 10 | This program is free software; you can redistribute it and/or modify it under |
paulb@304 | 11 | the terms of the GNU Lesser General Public License as published by the Free |
paulb@304 | 12 | Software Foundation; either version 3 of the License, or (at your option) any |
paulb@304 | 13 | later version. |
paulb@304 | 14 | |
paulb@304 | 15 | This program is distributed in the hope that it will be useful, but WITHOUT |
paulb@304 | 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paulb@304 | 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
paulb@304 | 18 | details. |
paulb@304 | 19 | |
paulb@304 | 20 | You should have received a copy of the GNU Lesser General Public License along |
paulb@304 | 21 | with this program. If not, see <http://www.gnu.org/licenses/>. |
paulb@304 | 22 | |
paulb@304 | 23 | -------- |
paulb@304 | 24 | |
paulb@304 | 25 | The sending and receiving of XML-RPC messages can be done using traditional HTTP |
paulb@304 | 26 | libraries. |
paulb@304 | 27 | |
paulb@304 | 28 | See tests/xmlrpc_test.py for more details. |
paulb@304 | 29 | """ |
paulb@304 | 30 | |
paulb@304 | 31 | import libxml2dom |
paulb@304 | 32 | from libxml2dom.macrolib import * |
paulb@304 | 33 | from libxml2dom.macrolib import \ |
paulb@304 | 34 | createDocument as Node_createDocument |
paulb@315 | 35 | import datetime |
paulb@304 | 36 | |
paulb@304 | 37 | class XMLRPCImplementation(libxml2dom.Implementation): |
paulb@304 | 38 | |
paulb@304 | 39 | "Contains an XML-RPC-specific implementation." |
paulb@304 | 40 | |
paulb@304 | 41 | # Wrapping of documents. |
paulb@304 | 42 | |
paulb@304 | 43 | def adoptDocument(self, node): |
paulb@304 | 44 | return XMLRPCDocument(node, self) |
paulb@304 | 45 | |
paulb@304 | 46 | # Factory functions. |
paulb@304 | 47 | |
paulb@304 | 48 | def get_node(self, _node, context_node): |
paulb@304 | 49 | |
paulb@304 | 50 | """ |
paulb@304 | 51 | Get a libxml2dom node for the given low-level '_node' and libxml2dom |
paulb@304 | 52 | 'context_node'. |
paulb@304 | 53 | """ |
paulb@304 | 54 | |
paulb@304 | 55 | if Node_nodeType(_node) == context_node.ELEMENT_NODE: |
paulb@304 | 56 | |
paulb@304 | 57 | # Make special elements. |
paulb@304 | 58 | |
paulb@304 | 59 | if Node_localName(_node) in ("methodCall", "methodResponse"): |
paulb@304 | 60 | return XMLRPCMethodElement(_node, self, context_node.ownerDocument) |
paulb@304 | 61 | elif Node_localName(_node) == "methodName": |
paulb@304 | 62 | return XMLRPCMethodNameElement(_node, self, context_node.ownerDocument) |
paulb@304 | 63 | elif Node_localName(_node) == "fault": |
paulb@304 | 64 | return XMLRPCFaultElement(_node, self, context_node.ownerDocument) |
paulb@304 | 65 | elif Node_localName(_node) == "string": |
paulb@304 | 66 | return XMLRPCStringElement(_node, self, context_node.ownerDocument) |
paulb@304 | 67 | elif Node_localName(_node) in ("int", "i4"): |
paulb@304 | 68 | return XMLRPCIntegerElement(_node, self, context_node.ownerDocument) |
paulb@304 | 69 | elif Node_localName(_node) == "boolean": |
paulb@304 | 70 | return XMLRPCBooleanElement(_node, self, context_node.ownerDocument) |
paulb@304 | 71 | elif Node_localName(_node) == "double": |
paulb@304 | 72 | return XMLRPCDoubleElement(_node, self, context_node.ownerDocument) |
paulb@304 | 73 | elif Node_localName(_node) == "dateTime.iso8601": |
paulb@304 | 74 | return XMLRPCDateTimeElement(_node, self, context_node.ownerDocument) |
paulb@304 | 75 | elif Node_localName(_node) == "base64": |
paulb@304 | 76 | return XMLRPCBase64Element(_node, self, context_node.ownerDocument) |
paulb@304 | 77 | elif Node_localName(_node) == "struct": |
paulb@304 | 78 | return XMLRPCStructElement(_node, self, context_node.ownerDocument) |
paulb@304 | 79 | elif Node_localName(_node) == "member": |
paulb@304 | 80 | return XMLRPCMemberElement(_node, self, context_node.ownerDocument) |
paulb@307 | 81 | elif Node_localName(_node) == "value": |
paulb@307 | 82 | return XMLRPCValueElement(_node, self, context_node.ownerDocument) |
paulb@309 | 83 | elif Node_localName(_node) == "name": |
paulb@309 | 84 | return XMLRPCNameElement(_node, self, context_node.ownerDocument) |
paulb@312 | 85 | elif Node_localName(_node) == "array": |
paulb@312 | 86 | return XMLRPCArrayElement(_node, self, context_node.ownerDocument) |
paulb@312 | 87 | elif Node_localName(_node) == "data": |
paulb@312 | 88 | return XMLRPCDataElement(_node, self, context_node.ownerDocument) |
paulb@304 | 89 | |
paulb@304 | 90 | # Otherwise, make generic XML-RPC elements. |
paulb@304 | 91 | |
paulb@304 | 92 | return XMLRPCElement(_node, self, context_node.ownerDocument) |
paulb@304 | 93 | |
paulb@304 | 94 | else: |
paulb@304 | 95 | return libxml2dom.Implementation.get_node(self, _node, context_node) |
paulb@304 | 96 | |
paulb@304 | 97 | # Convenience functions. |
paulb@304 | 98 | |
paulb@304 | 99 | def createXMLRPCMessage(self, namespaceURI, localName): |
paulb@304 | 100 | |
paulb@304 | 101 | "Create a new XML-RPC message document (fragment)." |
paulb@304 | 102 | |
paulb@304 | 103 | return XMLRPCDocument(Node_createDocument(namespaceURI, localName, None), self).documentElement |
paulb@304 | 104 | |
paulb@307 | 105 | def createMethodCall(self): |
paulb@307 | 106 | return self.createXMLRPCMessage(None, "methodCall") |
paulb@307 | 107 | |
paulb@307 | 108 | def createMethodResponse(self): |
paulb@307 | 109 | return self.createXMLRPCMessage(None, "methodResponse") |
paulb@307 | 110 | |
paulb@304 | 111 | # Node classes. |
paulb@304 | 112 | |
paulb@304 | 113 | class XMLRPCNode(libxml2dom.Node): |
paulb@304 | 114 | |
paulb@304 | 115 | "Convenience modifications to nodes specific to libxml2dom.xmlrpc." |
paulb@304 | 116 | |
paulb@304 | 117 | pass |
paulb@304 | 118 | |
paulb@307 | 119 | class XMLRPCElement(XMLRPCNode): |
paulb@307 | 120 | |
paulb@307 | 121 | "An XML-RPC element." |
paulb@307 | 122 | |
paulb@307 | 123 | pass |
paulb@307 | 124 | |
paulb@304 | 125 | class XMLRPCDocument(libxml2dom._Document, XMLRPCNode): |
paulb@304 | 126 | |
paulb@304 | 127 | "An XML-RPC document fragment." |
paulb@304 | 128 | |
paulb@304 | 129 | def _method(self): |
paulb@309 | 130 | return (self.xpath("methodCall|methodResponse") or [None])[0] |
paulb@307 | 131 | |
paulb@307 | 132 | def _fault(self): |
paulb@307 | 133 | if self.method is not None: |
paulb@307 | 134 | return self.method.fault |
paulb@307 | 135 | else: |
paulb@307 | 136 | return None |
paulb@304 | 137 | |
paulb@309 | 138 | method = property(_method) |
paulb@309 | 139 | fault = property(_fault) |
paulb@309 | 140 | |
paulb@307 | 141 | # Node construction methods. |
paulb@307 | 142 | |
paulb@307 | 143 | def createMethodCall(self): |
paulb@307 | 144 | return self.ownerDocument.createElement("methodCall") |
paulb@307 | 145 | |
paulb@307 | 146 | def createMethodResponse(self): |
paulb@307 | 147 | return self.ownerDocument.createElement("methodResponse") |
paulb@307 | 148 | |
paulb@304 | 149 | class XMLRPCMethodElement(XMLRPCNode): |
paulb@304 | 150 | |
paulb@304 | 151 | "An XML-RPC method element." |
paulb@304 | 152 | |
paulb@304 | 153 | def _fault(self): |
paulb@307 | 154 | return (self.xpath("./fault") or [None])[0] |
paulb@304 | 155 | |
paulb@309 | 156 | def _methodNameElement(self): |
paulb@307 | 157 | return (self.xpath("./methodName") or [None])[0] |
paulb@307 | 158 | |
paulb@309 | 159 | def _methodName(self): |
paulb@309 | 160 | name = self.methodNameElement |
paulb@307 | 161 | if name is not None: |
paulb@307 | 162 | return name.value |
paulb@307 | 163 | else: |
paulb@307 | 164 | return None |
paulb@307 | 165 | |
paulb@309 | 166 | def _setMethodName(self, name): |
paulb@309 | 167 | if self.methodNameElement is None: |
paulb@307 | 168 | methodName = self.createMethodName() |
paulb@307 | 169 | self.appendChild(methodName) |
paulb@309 | 170 | self.methodNameElement.value = name |
paulb@304 | 171 | |
paulb@314 | 172 | def _parameterValues(self): |
paulb@315 | 173 | return [value.container.contents for value in self.xpath("./params/param/value")] |
paulb@307 | 174 | |
paulb@307 | 175 | # Node construction methods. |
paulb@307 | 176 | |
paulb@307 | 177 | def createMethodName(self): |
paulb@307 | 178 | return self.ownerDocument.createElement("methodName") |
paulb@307 | 179 | |
paulb@307 | 180 | def createParameters(self): |
paulb@307 | 181 | return self.ownerDocument.createElement("params") |
paulb@307 | 182 | |
paulb@304 | 183 | def createFault(self): |
paulb@304 | 184 | return self.ownerDocument.createElement("fault") |
paulb@304 | 185 | |
paulb@304 | 186 | fault = property(_fault) |
paulb@309 | 187 | methodNameElement = property(_methodNameElement) |
paulb@309 | 188 | methodName = property(_methodName, _setMethodName) |
paulb@315 | 189 | parameterValues = property(_parameterValues) |
paulb@312 | 190 | |
paulb@312 | 191 | class XMLRPCArrayElement(XMLRPCNode): |
paulb@312 | 192 | |
paulb@312 | 193 | "An XML-RPC array element." |
paulb@312 | 194 | |
paulb@312 | 195 | def _data(self): |
paulb@312 | 196 | return (self.xpath("./data") or [None])[0] |
paulb@312 | 197 | |
paulb@315 | 198 | def _contents(self): |
paulb@315 | 199 | return self |
paulb@315 | 200 | |
paulb@315 | 201 | # Sequence emulation. |
paulb@315 | 202 | |
paulb@315 | 203 | def __len__(self): |
paulb@315 | 204 | if self.data: |
paulb@315 | 205 | return len(self.data) |
paulb@315 | 206 | else: |
paulb@315 | 207 | return 0 |
paulb@315 | 208 | |
paulb@315 | 209 | def __getitem__(self, i): |
paulb@315 | 210 | if self.data: |
paulb@315 | 211 | return self.data[i] |
paulb@315 | 212 | else: |
paulb@315 | 213 | raise IndexError, i |
paulb@315 | 214 | |
paulb@315 | 215 | def __eq__(self, other): |
paulb@315 | 216 | for i, j in map(None, self, other): |
paulb@315 | 217 | if i != j: |
paulb@315 | 218 | return False |
paulb@315 | 219 | return True |
paulb@315 | 220 | |
paulb@312 | 221 | # Node construction methods. |
paulb@312 | 222 | |
paulb@312 | 223 | def createData(self): |
paulb@312 | 224 | return self.ownerDocument.createElement("data") |
paulb@312 | 225 | |
paulb@312 | 226 | data = property(_data) |
paulb@315 | 227 | contents = property(_contents) |
paulb@309 | 228 | |
paulb@309 | 229 | class XMLRPCStructElement(XMLRPCNode): |
paulb@309 | 230 | |
paulb@309 | 231 | "An XML-RPC structure element." |
paulb@309 | 232 | |
paulb@309 | 233 | def _members(self): |
paulb@309 | 234 | return self.xpath("./member") |
paulb@309 | 235 | |
paulb@315 | 236 | def _contents(self): |
paulb@315 | 237 | return self |
paulb@315 | 238 | |
paulb@315 | 239 | # Sequence emulation. |
paulb@315 | 240 | |
paulb@315 | 241 | def __len__(self): |
paulb@315 | 242 | return len(self.members) |
paulb@315 | 243 | |
paulb@315 | 244 | def __getitem__(self, i): |
paulb@315 | 245 | return self.members[i] |
paulb@315 | 246 | |
paulb@315 | 247 | def __eq__(self, other): |
paulb@315 | 248 | for i, j in map(None, self, other): |
paulb@315 | 249 | if i != j: |
paulb@315 | 250 | return False |
paulb@315 | 251 | return True |
paulb@315 | 252 | |
paulb@309 | 253 | # Node construction methods. |
paulb@309 | 254 | |
paulb@309 | 255 | def createMember(self): |
paulb@309 | 256 | return self.ownerDocument.createElement("member") |
paulb@309 | 257 | |
paulb@309 | 258 | members = property(_members) |
paulb@315 | 259 | contents = property(_contents) |
paulb@309 | 260 | |
paulb@312 | 261 | class XMLRPCDataElement(XMLRPCNode): |
paulb@312 | 262 | |
paulb@312 | 263 | "An XML-RPC array data element." |
paulb@312 | 264 | |
paulb@312 | 265 | def _values(self): |
paulb@312 | 266 | return self.xpath("./value") |
paulb@312 | 267 | |
paulb@315 | 268 | # Sequence emulation. |
paulb@315 | 269 | |
paulb@315 | 270 | def __len__(self): |
paulb@315 | 271 | return len(self.values) |
paulb@315 | 272 | |
paulb@315 | 273 | def __getitem__(self, i): |
paulb@315 | 274 | return self.values[i].container.contents |
paulb@312 | 275 | |
paulb@312 | 276 | # Node construction methods. |
paulb@312 | 277 | |
paulb@312 | 278 | def createValue(self): |
paulb@312 | 279 | return self.ownerDocument.createElement("value") |
paulb@312 | 280 | |
paulb@315 | 281 | values = property(_values) |
paulb@315 | 282 | |
paulb@309 | 283 | class XMLRPCMemberElement(XMLRPCNode): |
paulb@309 | 284 | |
paulb@309 | 285 | "An XML-RPC structure member element." |
paulb@309 | 286 | |
paulb@312 | 287 | def _value(self): |
paulb@312 | 288 | return (self.xpath("./value") or [None])[0] |
paulb@312 | 289 | |
paulb@309 | 290 | def _nameElement(self): |
paulb@309 | 291 | return (self.xpath("./name") or [None])[0] |
paulb@309 | 292 | |
paulb@309 | 293 | def _memberName(self): |
paulb@309 | 294 | if self.nameElement is not None: |
paulb@309 | 295 | return self.nameElement.value |
paulb@309 | 296 | else: |
paulb@309 | 297 | return None |
paulb@309 | 298 | |
paulb@309 | 299 | def _setMemberName(self, name): |
paulb@309 | 300 | if self.nameElement is None: |
paulb@309 | 301 | nameElement = self.createName() |
paulb@309 | 302 | self.appendChild(nameElement) |
paulb@309 | 303 | self.nameElement.value = name |
paulb@309 | 304 | |
paulb@315 | 305 | def _contents(self): |
paulb@315 | 306 | return self |
paulb@315 | 307 | |
paulb@315 | 308 | # Item (name, value) emulation. |
paulb@315 | 309 | |
paulb@315 | 310 | def __len__(self): |
paulb@315 | 311 | return 2 |
paulb@315 | 312 | |
paulb@315 | 313 | def __getitem__(self, i): |
paulb@315 | 314 | return (self.memberName, self.value.container.contents)[i] |
paulb@315 | 315 | |
paulb@315 | 316 | def __eq__(self, other): |
paulb@315 | 317 | return self[0] == other[0] and self[1] == other[1] |
paulb@315 | 318 | |
paulb@309 | 319 | # Node construction methods. |
paulb@309 | 320 | |
paulb@309 | 321 | def createName(self): |
paulb@309 | 322 | return self.ownerDocument.createElement("name") |
paulb@309 | 323 | |
paulb@309 | 324 | def createValue(self): |
paulb@309 | 325 | return self.ownerDocument.createElement("value") |
paulb@309 | 326 | |
paulb@312 | 327 | value = property(_value) |
paulb@309 | 328 | nameElement = property(_nameElement) |
paulb@309 | 329 | memberName = property(_memberName, _setMemberName) |
paulb@315 | 330 | contents = property(_contents) |
paulb@304 | 331 | |
paulb@304 | 332 | class XMLRPCStringElement(XMLRPCNode): |
paulb@304 | 333 | |
paulb@304 | 334 | "An XML-RPC string element." |
paulb@304 | 335 | |
paulb@315 | 336 | typename = "string" |
paulb@315 | 337 | |
paulb@304 | 338 | def _value(self): |
paulb@304 | 339 | return self.textContent.strip() |
paulb@304 | 340 | |
paulb@304 | 341 | def _setValue(self, value): |
paulb@304 | 342 | for node in self.childNodes: |
paulb@304 | 343 | self.removeChild(node) |
paulb@304 | 344 | text = self.ownerDocument.createTextNode(value) |
paulb@304 | 345 | self.appendChild(text) |
paulb@304 | 346 | |
paulb@315 | 347 | def _contents(self): |
paulb@315 | 348 | return convert(self.typename, self.value) |
paulb@315 | 349 | |
paulb@315 | 350 | def __eq__(self, other): |
paulb@315 | 351 | if hasattr(other, "contents"): |
paulb@315 | 352 | return self.contents == other.contents |
paulb@315 | 353 | else: |
paulb@315 | 354 | return self.contents == other |
paulb@315 | 355 | |
paulb@304 | 356 | value = property(_value, _setValue) |
paulb@315 | 357 | contents = property(_contents) |
paulb@304 | 358 | |
paulb@309 | 359 | class XMLRPCNameElement(XMLRPCStringElement): |
paulb@309 | 360 | |
paulb@309 | 361 | "An XML-RPC name element." |
paulb@309 | 362 | |
paulb@309 | 363 | pass |
paulb@309 | 364 | |
paulb@307 | 365 | class XMLRPCValueElement(XMLRPCStringElement): |
paulb@307 | 366 | |
paulb@307 | 367 | "An XML-RPC value element." |
paulb@307 | 368 | |
paulb@307 | 369 | def _type(self): |
paulb@307 | 370 | elements = self.xpath("*") |
paulb@307 | 371 | if elements: |
paulb@307 | 372 | return elements[0].localName |
paulb@307 | 373 | else: |
paulb@307 | 374 | return "string" |
paulb@307 | 375 | |
paulb@307 | 376 | def _container(self): |
paulb@307 | 377 | return (self.xpath("*") or [self])[0] |
paulb@307 | 378 | |
paulb@307 | 379 | type = property(_type) |
paulb@307 | 380 | container = property(_container) |
paulb@307 | 381 | |
paulb@304 | 382 | class XMLRPCMethodNameElement(XMLRPCStringElement): |
paulb@304 | 383 | |
paulb@304 | 384 | "An XML-RPC method element." |
paulb@304 | 385 | |
paulb@304 | 386 | pass |
paulb@304 | 387 | |
paulb@304 | 388 | class XMLRPCIntegerElement(XMLRPCStringElement): |
paulb@304 | 389 | |
paulb@304 | 390 | "An XML-RPC integer element." |
paulb@304 | 391 | |
paulb@315 | 392 | typename = "int" |
paulb@304 | 393 | |
paulb@304 | 394 | class XMLRPCBooleanElement(XMLRPCStringElement): |
paulb@304 | 395 | |
paulb@304 | 396 | "An XML-RPC boolean element." |
paulb@304 | 397 | |
paulb@315 | 398 | typename = "boolean" |
paulb@304 | 399 | |
paulb@304 | 400 | class XMLRPCDoubleElement(XMLRPCStringElement): |
paulb@304 | 401 | |
paulb@304 | 402 | "An XML-RPC double floating point number element." |
paulb@304 | 403 | |
paulb@315 | 404 | typename = "double" |
paulb@304 | 405 | |
paulb@304 | 406 | class XMLRPCDateTimeElement(XMLRPCStringElement): |
paulb@304 | 407 | |
paulb@304 | 408 | "An XML-RPC date/time element." |
paulb@304 | 409 | |
paulb@315 | 410 | typename = "datetime" |
paulb@304 | 411 | |
paulb@304 | 412 | class XMLRPCBase64Element(XMLRPCStringElement): |
paulb@304 | 413 | |
paulb@304 | 414 | "An XML-RPC integer element." |
paulb@304 | 415 | |
paulb@315 | 416 | typename = "base64" |
paulb@304 | 417 | |
paulb@304 | 418 | class XMLRPCFaultElement(XMLRPCNode): |
paulb@304 | 419 | |
paulb@304 | 420 | "An XML-RPC fault element." |
paulb@304 | 421 | |
paulb@304 | 422 | def _code(self): |
paulb@307 | 423 | code = self.xpath("./value/struct/member[./name/text() = 'faultCode']/value/int") |
paulb@307 | 424 | if code: |
paulb@307 | 425 | return code[0].value |
paulb@307 | 426 | else: |
paulb@307 | 427 | return None |
paulb@304 | 428 | |
paulb@304 | 429 | def _reason(self): |
paulb@307 | 430 | reason = self.xpath("./value/struct/member[./name/text() = 'faultString']/value/string") |
paulb@307 | 431 | if reason: |
paulb@307 | 432 | return reason[0].value |
paulb@307 | 433 | else: |
paulb@307 | 434 | return None |
paulb@304 | 435 | |
paulb@304 | 436 | code = property(_code) |
paulb@304 | 437 | reason = property(_reason) |
paulb@304 | 438 | |
paulb@315 | 439 | # Conversion functions. |
paulb@315 | 440 | |
paulb@315 | 441 | def convert(typename, value): |
paulb@315 | 442 | return default_converters[typename](value) |
paulb@315 | 443 | |
paulb@315 | 444 | def boolean(s): |
paulb@315 | 445 | if s.lower() == "true": |
paulb@315 | 446 | return True |
paulb@315 | 447 | elif s.lower() == "false": |
paulb@315 | 448 | return False |
paulb@315 | 449 | else: |
paulb@315 | 450 | raise ValueError, "String value %s not convertable to boolean." % repr(s) |
paulb@315 | 451 | |
paulb@315 | 452 | def iso8601(s): |
paulb@315 | 453 | year, month, day, hour, minute, second = map(int, (s[:4], s[4:6], s[6:8], s[9:11], s[12:14], s[15:17])) |
paulb@315 | 454 | return datetime.datetime(year, month, day, hour, minute, second) |
paulb@315 | 455 | |
paulb@315 | 456 | default_converters = { |
paulb@315 | 457 | "string" : unicode, |
paulb@315 | 458 | "int" : int, |
paulb@315 | 459 | "i4" : int, |
paulb@315 | 460 | "double" : float, |
paulb@315 | 461 | "boolean" : boolean, |
paulb@315 | 462 | "dateTime.iso8601" : iso8601, |
paulb@315 | 463 | "base64" : str |
paulb@315 | 464 | } |
paulb@315 | 465 | |
paulb@304 | 466 | # Utility functions. |
paulb@304 | 467 | |
paulb@304 | 468 | createDocument = libxml2dom.createDocument |
paulb@304 | 469 | createDocumentType = libxml2dom.createDocumentType |
paulb@304 | 470 | |
paulb@304 | 471 | def createXMLRPCMessage(namespaceURI, localName): |
paulb@307 | 472 | return default_impl.createXMLRPCMessage(None, localName) |
paulb@307 | 473 | |
paulb@307 | 474 | def createMethodCall(): |
paulb@307 | 475 | return default_impl.createMethodCall() |
paulb@307 | 476 | |
paulb@307 | 477 | def createMethodResponse(): |
paulb@307 | 478 | return default_impl.createMethodResponse() |
paulb@304 | 479 | |
paulb@304 | 480 | def parse(stream_or_string, html=0, htmlencoding=None, unfinished=0, impl=None): |
paulb@304 | 481 | return libxml2dom.parse(stream_or_string, html=html, htmlencoding=htmlencoding, unfinished=unfinished, impl=(impl or default_impl)) |
paulb@304 | 482 | |
paulb@304 | 483 | def parseFile(filename, html=0, htmlencoding=None, unfinished=0, impl=None): |
paulb@304 | 484 | return libxml2dom.parseFile(filename, html=html, htmlencoding=htmlencoding, unfinished=unfinished, impl=(impl or default_impl)) |
paulb@304 | 485 | |
paulb@304 | 486 | def parseString(s, html=0, htmlencoding=None, unfinished=0, impl=None): |
paulb@304 | 487 | return libxml2dom.parseString(s, html=html, htmlencoding=htmlencoding, unfinished=unfinished, impl=(impl or default_impl)) |
paulb@304 | 488 | |
paulb@304 | 489 | def parseURI(uri, html=0, htmlencoding=None, unfinished=0, impl=None): |
paulb@304 | 490 | return libxml2dom.parseURI(uri, html=html, htmlencoding=htmlencoding, unfinished=unfinished, impl=(impl or default_impl)) |
paulb@304 | 491 | |
paulb@304 | 492 | # Single instance of the implementation. |
paulb@304 | 493 | |
paulb@304 | 494 | default_impl = XMLRPCImplementation() |
paulb@304 | 495 | |
paulb@304 | 496 | # vim: tabstop=4 expandtab shiftwidth=4 |