Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Doc/library/xmlrpclib.rst

    r2 r391  
    99.. note::
    1010   The :mod:`xmlrpclib` module has been renamed to :mod:`xmlrpc.client` in
    11    Python 3.0.  The :term:`2to3` tool will automatically adapt imports when
    12    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.
    1313
    1414
     
    1717
    1818.. versionadded:: 2.2
     19
     20**Source code:** :source:`Lib/xmlrpclib.py`
     21
     22--------------
    1923
    2024XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP as a
     
    2327supports writing XML-RPC client code; it handles all the details of translating
    2428between 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`.
    2536
    2637
     
    149160
    150161Servers that support the XML introspection API support some common methods
    151 grouped under the reserved :attr:`system` member:
     162grouped under the reserved :attr:`system` attribute:
    152163
    153164
     
    342353
    343354A :class:`Fault` object encapsulates the content of an XML-RPC fault tag. Fault
    344 objects have the following members:
     355objects have the following attributes:
    345356
    346357
     
    377388   try:
    378389       proxy.add(2, 5)
    379    except xmlrpclib.Fault, err:
     390   except xmlrpclib.Fault as err:
    380391       print "A fault occurred"
    381392       print "Fault code: %d" % err.faultCode
     
    391402A :class:`ProtocolError` object describes a protocol error in the underlying
    392403transport layer (such as a 404 'not found' error if the server named by the URI
    393 does not exist).  It has the following members:
     404does not exist).  It has the following attributes:
    394405
    395406
     
    415426
    416427In 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 URI
    422    proxy = xmlrpclib.ServerProxy("http://invalidaddress/")
     428by 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/")
    423434
    424435   try:
    425436       proxy.some_method()
    426    except xmlrpclib.ProtocolError, err:
     437   except xmlrpclib.ProtocolError as err:
    427438       print "A protocol error occurred"
    428439       print "URL: %s" % err.url
     
    436447.. versionadded:: 2.4
    437448
    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.
     449The :class:`MultiCall` object provides a way to encapsulate multiple calls to a
     450remote server into a single request [#]_.
    440451
    441452
     
    542553   try:
    543554       print server.examples.getStateName(41)
    544    except Error, v:
     555   except Error as v:
    545556       print "ERROR", v
    546557
     
    578589
    579590
     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.