Changeset 391 for python/trunk/Doc/library/xmlrpclib.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/xmlrpclib.rst
r2 r391 9 9 .. note:: 10 10 The :mod:`xmlrpclib` module has been renamed to :mod:`xmlrpc.client` in 11 Python 3. 0.The :term:`2to3` tool will automatically adapt imports when12 converting your sources to 3.0.11 Python 3. The :term:`2to3` tool will automatically adapt imports when 12 converting your sources to Python 3. 13 13 14 14 … … 17 17 18 18 .. versionadded:: 2.2 19 20 **Source code:** :source:`Lib/xmlrpclib.py` 21 22 -------------- 19 23 20 24 XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP as a … … 23 27 supports writing XML-RPC client code; it handles all the details of translating 24 28 between conformable Python objects and XML on the wire. 29 30 31 .. warning:: 32 33 The :mod:`xmlrpclib` module is not secure against maliciously 34 constructed data. If you need to parse untrusted or unauthenticated data see 35 :ref:`xml-vulnerabilities`. 25 36 26 37 … … 149 160 150 161 Servers that support the XML introspection API support some common methods 151 grouped under the reserved :attr:`system` member:162 grouped under the reserved :attr:`system` attribute: 152 163 153 164 … … 342 353 343 354 A :class:`Fault` object encapsulates the content of an XML-RPC fault tag. Fault 344 objects have the following members:355 objects have the following attributes: 345 356 346 357 … … 377 388 try: 378 389 proxy.add(2, 5) 379 except xmlrpclib.Fault ,err:390 except xmlrpclib.Fault as err: 380 391 print "A fault occurred" 381 392 print "Fault code: %d" % err.faultCode … … 391 402 A :class:`ProtocolError` object describes a protocol error in the underlying 392 403 transport layer (such as a 404 'not found' error if the server named by the URI 393 does not exist). It has the following members:404 does not exist). It has the following attributes: 394 405 395 406 … … 415 426 416 427 In the following example we're going to intentionally cause a :exc:`ProtocolError` 417 by providing an invalid URI::418 419 import xmlrpclib 420 421 # create a ServerProxy with an invalid URI422 proxy = xmlrpclib.ServerProxy("http:// invalidaddress/")428 by providing an URI that doesn't point to an XMLRPC server:: 429 430 import xmlrpclib 431 432 # create a ServerProxy with an URI that doesn't respond to XMLRPC requests 433 proxy = xmlrpclib.ServerProxy("http://www.google.com/") 423 434 424 435 try: 425 436 proxy.some_method() 426 except xmlrpclib.ProtocolError ,err:437 except xmlrpclib.ProtocolError as err: 427 438 print "A protocol error occurred" 428 439 print "URL: %s" % err.url … … 436 447 .. versionadded:: 2.4 437 448 438 In http://www.xmlrpc.com/discuss/msgReader%241208, an approach is presented to 439 encapsulate multiple calls to a remote server into a single request.449 The :class:`MultiCall` object provides a way to encapsulate multiple calls to a 450 remote server into a single request [#]_. 440 451 441 452 … … 542 553 try: 543 554 print server.examples.getStateName(41) 544 except Error ,v:555 except Error as v: 545 556 print "ERROR", v 546 557 … … 578 589 579 590 591 .. rubric:: Footnotes 592 593 .. [#] This approach has been first presented in `a discussion on xmlrpc.com 594 <http://web.archive.org/web/20060624230303/http://www.xmlrpc.com/discuss/msgReader$1208?mode=topic>`_. 595 .. the link now points to webarchive since the one at 596 .. http://www.xmlrpc.com/discuss/msgReader%241208 is broken (and webadmin 597 .. doesn't reply)
Note:
See TracChangeset
for help on using the changeset viewer.