Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > contrib-backports > by-pkgid > 3ba3bd1608c672ba2129b098a48e9e4d > files > 864

python3-docs-3.2.2-3mdv2010.2.noarch.rpm



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>20.24. xmlrpc.server — Basic XML-RPC servers &mdash; Python v3.2.2 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '3.2.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python v3.2.2 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="top" title="Python v3.2.2 documentation" href="../index.html" />
    <link rel="up" title="20. Internet Protocols and Support" href="internet.html" />
    <link rel="next" title="21. Multimedia Services" href="mm.html" />
    <link rel="prev" title="20.23. xmlrpc.client — XML-RPC client access" href="xmlrpc.client.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
 

  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="mm.html" title="21. Multimedia Services"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="xmlrpc.client.html" title="20.23. xmlrpc.client — XML-RPC client access"
             accesskey="P">previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="../index.html">Python v3.2.2 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="internet.html" accesskey="U">20. Internet Protocols and Support</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-xmlrpc.server">
<span id="xmlrpc-server-basic-xml-rpc-servers"></span><h1>20.24. <a class="reference internal" href="#module-xmlrpc.server" title="xmlrpc.server: Basic XML-RPC server implementations."><tt class="xref py py-mod docutils literal"><span class="pre">xmlrpc.server</span></tt></a> &#8212; Basic XML-RPC servers<a class="headerlink" href="#module-xmlrpc.server" title="Permalink to this headline">¶</a></h1>
<p><strong>Source code:</strong> <a class="reference external" href="http://hg.python.org/cpython/file/3.2/Lib/xmlrpc/server.py">Lib/xmlrpc/server.py</a></p>
<hr class="docutils" />
<p>The <a class="reference internal" href="#module-xmlrpc.server" title="xmlrpc.server: Basic XML-RPC server implementations."><tt class="xref py py-mod docutils literal"><span class="pre">xmlrpc.server</span></tt></a> module provides a basic server framework for XML-RPC
servers written in Python.  Servers can either be free standing, using
<a class="reference internal" href="#xmlrpc.server.SimpleXMLRPCServer" title="xmlrpc.server.SimpleXMLRPCServer"><tt class="xref py py-class docutils literal"><span class="pre">SimpleXMLRPCServer</span></tt></a>, or embedded in a CGI environment, using
<a class="reference internal" href="#xmlrpc.server.CGIXMLRPCRequestHandler" title="xmlrpc.server.CGIXMLRPCRequestHandler"><tt class="xref py py-class docutils literal"><span class="pre">CGIXMLRPCRequestHandler</span></tt></a>.</p>
<dl class="class">
<dt id="xmlrpc.server.SimpleXMLRPCServer">
<em class="property">class </em><tt class="descclassname">xmlrpc.server.</tt><tt class="descname">SimpleXMLRPCServer</tt><big>(</big><em>addr</em>, <em>requestHandler=SimpleXMLRPCRequestHandler</em>, <em>logRequests=True</em>, <em>allow_none=False</em>, <em>encoding=None</em>, <em>bind_and_activate=True</em><big>)</big><a class="headerlink" href="#xmlrpc.server.SimpleXMLRPCServer" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new server instance.  This class provides methods for registration of
functions that can be called by the XML-RPC protocol.  The <em>requestHandler</em>
parameter should be a factory for request handler instances; it defaults to
<a class="reference internal" href="#xmlrpc.server.SimpleXMLRPCRequestHandler" title="xmlrpc.server.SimpleXMLRPCRequestHandler"><tt class="xref py py-class docutils literal"><span class="pre">SimpleXMLRPCRequestHandler</span></tt></a>.  The <em>addr</em> and <em>requestHandler</em> parameters
are passed to the <tt class="xref py py-class docutils literal"><span class="pre">socketserver.TCPServer</span></tt> constructor.  If <em>logRequests</em>
is true (the default), requests will be logged; setting this parameter to false
will turn off logging.   The <em>allow_none</em> and <em>encoding</em> parameters are passed
on to  <a class="reference internal" href="xmlrpc.client.html#module-xmlrpc.client" title="xmlrpc.client: XML-RPC client access."><tt class="xref py py-mod docutils literal"><span class="pre">xmlrpc.client</span></tt></a> and control the XML-RPC responses that will be returned
from the server. The <em>bind_and_activate</em> parameter controls whether
<tt class="xref py py-meth docutils literal"><span class="pre">server_bind()</span></tt> and <tt class="xref py py-meth docutils literal"><span class="pre">server_activate()</span></tt> are called immediately by the
constructor; it defaults to true. Setting it to false allows code to manipulate
the <em>allow_reuse_address</em> class variable before the address is bound.</p>
</dd></dl>

<dl class="class">
<dt id="xmlrpc.server.CGIXMLRPCRequestHandler">
<em class="property">class </em><tt class="descclassname">xmlrpc.server.</tt><tt class="descname">CGIXMLRPCRequestHandler</tt><big>(</big><em>allow_none=False</em>, <em>encoding=None</em><big>)</big><a class="headerlink" href="#xmlrpc.server.CGIXMLRPCRequestHandler" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new instance to handle XML-RPC requests in a CGI environment.  The
<em>allow_none</em> and <em>encoding</em> parameters are passed on to <a class="reference internal" href="xmlrpc.client.html#module-xmlrpc.client" title="xmlrpc.client: XML-RPC client access."><tt class="xref py py-mod docutils literal"><span class="pre">xmlrpc.client</span></tt></a>
and control the XML-RPC responses that will be returned from the server.</p>
</dd></dl>

<dl class="class">
<dt id="xmlrpc.server.SimpleXMLRPCRequestHandler">
<em class="property">class </em><tt class="descclassname">xmlrpc.server.</tt><tt class="descname">SimpleXMLRPCRequestHandler</tt><a class="headerlink" href="#xmlrpc.server.SimpleXMLRPCRequestHandler" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new request handler instance.  This request handler supports <tt class="docutils literal"><span class="pre">POST</span></tt>
requests and modifies logging so that the <em>logRequests</em> parameter to the
<a class="reference internal" href="#xmlrpc.server.SimpleXMLRPCServer" title="xmlrpc.server.SimpleXMLRPCServer"><tt class="xref py py-class docutils literal"><span class="pre">SimpleXMLRPCServer</span></tt></a> constructor parameter is honored.</p>
</dd></dl>

<div class="section" id="simplexmlrpcserver-objects">
<span id="simple-xmlrpc-servers"></span><h2>20.24.1. SimpleXMLRPCServer Objects<a class="headerlink" href="#simplexmlrpcserver-objects" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference internal" href="#xmlrpc.server.SimpleXMLRPCServer" title="xmlrpc.server.SimpleXMLRPCServer"><tt class="xref py py-class docutils literal"><span class="pre">SimpleXMLRPCServer</span></tt></a> class is based on
<tt class="xref py py-class docutils literal"><span class="pre">socketserver.TCPServer</span></tt> and provides a means of creating simple, stand
alone XML-RPC servers.</p>
<dl class="method">
<dt id="xmlrpc.server.SimpleXMLRPCServer.register_function">
<tt class="descclassname">SimpleXMLRPCServer.</tt><tt class="descname">register_function</tt><big>(</big><em>function</em>, <em>name=None</em><big>)</big><a class="headerlink" href="#xmlrpc.server.SimpleXMLRPCServer.register_function" title="Permalink to this definition">¶</a></dt>
<dd><p>Register a function that can respond to XML-RPC requests.  If <em>name</em> is given,
it will be the method name associated with <em>function</em>, otherwise
<tt class="docutils literal"><span class="pre">function.__name__</span></tt> will be used.  <em>name</em> can be either a normal or Unicode
string, and may contain characters not legal in Python identifiers, including
the period character.</p>
</dd></dl>

<dl class="method">
<dt id="xmlrpc.server.SimpleXMLRPCServer.register_instance">
<tt class="descclassname">SimpleXMLRPCServer.</tt><tt class="descname">register_instance</tt><big>(</big><em>instance</em>, <em>allow_dotted_names=False</em><big>)</big><a class="headerlink" href="#xmlrpc.server.SimpleXMLRPCServer.register_instance" title="Permalink to this definition">¶</a></dt>
<dd><p>Register an object which is used to expose method names which have not been
registered using <a class="reference internal" href="#xmlrpc.server.SimpleXMLRPCServer.register_function" title="xmlrpc.server.SimpleXMLRPCServer.register_function"><tt class="xref py py-meth docutils literal"><span class="pre">register_function()</span></tt></a>.  If <em>instance</em> contains a
<tt class="xref py py-meth docutils literal"><span class="pre">_dispatch()</span></tt> method, it is called with the requested method name and the
parameters from the request.  Its API is <tt class="docutils literal"><span class="pre">def</span> <span class="pre">_dispatch(self,</span> <span class="pre">method,</span> <span class="pre">params)</span></tt>
(note that <em>params</em> does not represent a variable argument list).  If it calls
an underlying function to perform its task, that function is called as
<tt class="docutils literal"><span class="pre">func(*params)</span></tt>, expanding the parameter list. The return value from
<tt class="xref py py-meth docutils literal"><span class="pre">_dispatch()</span></tt> is returned to the client as the result.  If <em>instance</em> does
not have a <tt class="xref py py-meth docutils literal"><span class="pre">_dispatch()</span></tt> method, it is searched for an attribute matching
the name of the requested method.</p>
<p>If the optional <em>allow_dotted_names</em> argument is true and the instance does not
have a <tt class="xref py py-meth docutils literal"><span class="pre">_dispatch()</span></tt> method, then if the requested method name contains
periods, each component of the method name is searched for individually, with
the effect that a simple hierarchical search is performed.  The value found from
this search is then called with the parameters from the request, and the return
value is passed back to the client.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">Enabling the <em>allow_dotted_names</em> option allows intruders to access your
module&#8217;s global variables and may allow intruders to execute arbitrary code on
your machine.  Only use this option on a secure, closed network.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="xmlrpc.server.SimpleXMLRPCServer.register_introspection_functions">
<tt class="descclassname">SimpleXMLRPCServer.</tt><tt class="descname">register_introspection_functions</tt><big>(</big><big>)</big><a class="headerlink" href="#xmlrpc.server.SimpleXMLRPCServer.register_introspection_functions" title="Permalink to this definition">¶</a></dt>
<dd><p>Registers the XML-RPC introspection functions <tt class="docutils literal"><span class="pre">system.listMethods</span></tt>,
<tt class="docutils literal"><span class="pre">system.methodHelp</span></tt> and <tt class="docutils literal"><span class="pre">system.methodSignature</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="xmlrpc.server.SimpleXMLRPCServer.register_multicall_functions">
<tt class="descclassname">SimpleXMLRPCServer.</tt><tt class="descname">register_multicall_functions</tt><big>(</big><big>)</big><a class="headerlink" href="#xmlrpc.server.SimpleXMLRPCServer.register_multicall_functions" title="Permalink to this definition">¶</a></dt>
<dd><p>Registers the XML-RPC multicall function system.multicall.</p>
</dd></dl>

<dl class="attribute">
<dt id="xmlrpc.server.SimpleXMLRPCRequestHandler.rpc_paths">
<tt class="descclassname">SimpleXMLRPCRequestHandler.</tt><tt class="descname">rpc_paths</tt><a class="headerlink" href="#xmlrpc.server.SimpleXMLRPCRequestHandler.rpc_paths" title="Permalink to this definition">¶</a></dt>
<dd><p>An attribute value that must be a tuple listing valid path portions of the URL
for receiving XML-RPC requests.  Requests posted to other paths will result in a
404 &#8220;no such page&#8221; HTTP error.  If this tuple is empty, all paths will be
considered valid. The default value is <tt class="docutils literal"><span class="pre">('/',</span> <span class="pre">'/RPC2')</span></tt>.</p>
</dd></dl>

<div class="section" id="simplexmlrpcserver-example">
<span id="id1"></span><h3>20.24.1.1. SimpleXMLRPCServer Example<a class="headerlink" href="#simplexmlrpcserver-example" title="Permalink to this headline">¶</a></h3>
<p>Server code:</p>
<div class="highlight-python3"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">xmlrpc.server</span> <span class="k">import</span> <span class="n">SimpleXMLRPCServer</span>
<span class="kn">from</span> <span class="nn">xmlrpc.server</span> <span class="k">import</span> <span class="n">SimpleXMLRPCRequestHandler</span>

<span class="c"># Restrict to a particular path.</span>
<span class="k">class</span> <span class="nc">RequestHandler</span><span class="p">(</span><span class="n">SimpleXMLRPCRequestHandler</span><span class="p">):</span>
    <span class="n">rpc_paths</span> <span class="o">=</span> <span class="p">(</span><span class="s">&#39;/RPC2&#39;</span><span class="p">,)</span>

<span class="c"># Create server</span>
<span class="n">server</span> <span class="o">=</span> <span class="n">SimpleXMLRPCServer</span><span class="p">((</span><span class="s">&quot;localhost&quot;</span><span class="p">,</span> <span class="mi">8000</span><span class="p">),</span>
                            <span class="n">requestHandler</span><span class="o">=</span><span class="n">RequestHandler</span><span class="p">)</span>
<span class="n">server</span><span class="o">.</span><span class="n">register_introspection_functions</span><span class="p">()</span>

<span class="c"># Register pow() function; this will use the value of</span>
<span class="c"># pow.__name__ as the name, which is just &#39;pow&#39;.</span>
<span class="n">server</span><span class="o">.</span><span class="n">register_function</span><span class="p">(</span><span class="nb">pow</span><span class="p">)</span>

<span class="c"># Register a function under a different name</span>
<span class="k">def</span> <span class="nf">adder_function</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span>
<span class="n">server</span><span class="o">.</span><span class="n">register_function</span><span class="p">(</span><span class="n">adder_function</span><span class="p">,</span> <span class="s">&#39;add&#39;</span><span class="p">)</span>

<span class="c"># Register an instance; all the methods of the instance are</span>
<span class="c"># published as XML-RPC methods (in this case, just &#39;mul&#39;).</span>
<span class="k">class</span> <span class="nc">MyFuncs</span><span class="p">:</span>
    <span class="k">def</span> <span class="nf">mul</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">x</span> <span class="o">*</span> <span class="n">y</span>

<span class="n">server</span><span class="o">.</span><span class="n">register_instance</span><span class="p">(</span><span class="n">MyFuncs</span><span class="p">())</span>

<span class="c"># Run the server&#39;s main loop</span>
<span class="n">server</span><span class="o">.</span><span class="n">serve_forever</span><span class="p">()</span>
</pre></div>
</div>
<p>The following client code will call the methods made available by the preceding
server:</p>
<div class="highlight-python3"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">xmlrpc.client</span>

<span class="n">s</span> <span class="o">=</span> <span class="n">xmlrpc</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">ServerProxy</span><span class="p">(</span><span class="s">&#39;http://localhost:8000&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">pow</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">))</span>  <span class="c"># Returns 2**3 = 8</span>
<span class="nb">print</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">))</span>  <span class="c"># Returns 5</span>
<span class="nb">print</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">mul</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">2</span><span class="p">))</span>  <span class="c"># Returns 5*2 = 10</span>

<span class="c"># Print list of available methods</span>
<span class="nb">print</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">system</span><span class="o">.</span><span class="n">listMethods</span><span class="p">())</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="cgixmlrpcrequesthandler">
<h2>20.24.2. CGIXMLRPCRequestHandler<a class="headerlink" href="#cgixmlrpcrequesthandler" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference internal" href="#xmlrpc.server.CGIXMLRPCRequestHandler" title="xmlrpc.server.CGIXMLRPCRequestHandler"><tt class="xref py py-class docutils literal"><span class="pre">CGIXMLRPCRequestHandler</span></tt></a> class can be used to  handle XML-RPC
requests sent to Python CGI scripts.</p>
<dl class="method">
<dt id="xmlrpc.server.CGIXMLRPCRequestHandler.register_function">
<tt class="descclassname">CGIXMLRPCRequestHandler.</tt><tt class="descname">register_function</tt><big>(</big><em>function</em>, <em>name=None</em><big>)</big><a class="headerlink" href="#xmlrpc.server.CGIXMLRPCRequestHandler.register_function" title="Permalink to this definition">¶</a></dt>
<dd><p>Register a function that can respond to XML-RPC requests. If  <em>name</em> is given,
it will be the method name associated with  function, otherwise
<em>function.__name__</em> will be used. <em>name</em> can be either a normal or Unicode
string, and may contain  characters not legal in Python identifiers, including
the period character.</p>
</dd></dl>

<dl class="method">
<dt id="xmlrpc.server.CGIXMLRPCRequestHandler.register_instance">
<tt class="descclassname">CGIXMLRPCRequestHandler.</tt><tt class="descname">register_instance</tt><big>(</big><em>instance</em><big>)</big><a class="headerlink" href="#xmlrpc.server.CGIXMLRPCRequestHandler.register_instance" title="Permalink to this definition">¶</a></dt>
<dd><p>Register an object which is used to expose method names  which have not been
registered using <a class="reference internal" href="#xmlrpc.server.CGIXMLRPCRequestHandler.register_function" title="xmlrpc.server.CGIXMLRPCRequestHandler.register_function"><tt class="xref py py-meth docutils literal"><span class="pre">register_function()</span></tt></a>. If  instance contains a
<tt class="xref py py-meth docutils literal"><span class="pre">_dispatch()</span></tt> method, it is called with the  requested method name and the
parameters from the  request; the return value is returned to the client as the
result. If instance does not have a <tt class="xref py py-meth docutils literal"><span class="pre">_dispatch()</span></tt> method, it is searched
for an attribute matching the name of the requested method; if  the requested
method name contains periods, each  component of the method name is searched for
individually,  with the effect that a simple hierarchical search is performed.
The value found from this search is then called with the  parameters from the
request, and the return value is passed  back to the client.</p>
</dd></dl>

<dl class="method">
<dt id="xmlrpc.server.CGIXMLRPCRequestHandler.register_introspection_functions">
<tt class="descclassname">CGIXMLRPCRequestHandler.</tt><tt class="descname">register_introspection_functions</tt><big>(</big><big>)</big><a class="headerlink" href="#xmlrpc.server.CGIXMLRPCRequestHandler.register_introspection_functions" title="Permalink to this definition">¶</a></dt>
<dd><p>Register the XML-RPC introspection functions  <tt class="docutils literal"><span class="pre">system.listMethods</span></tt>,
<tt class="docutils literal"><span class="pre">system.methodHelp</span></tt> and  <tt class="docutils literal"><span class="pre">system.methodSignature</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="xmlrpc.server.CGIXMLRPCRequestHandler.register_multicall_functions">
<tt class="descclassname">CGIXMLRPCRequestHandler.</tt><tt class="descname">register_multicall_functions</tt><big>(</big><big>)</big><a class="headerlink" href="#xmlrpc.server.CGIXMLRPCRequestHandler.register_multicall_functions" title="Permalink to this definition">¶</a></dt>
<dd><p>Register the XML-RPC multicall function <tt class="docutils literal"><span class="pre">system.multicall</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="xmlrpc.server.CGIXMLRPCRequestHandler.handle_request">
<tt class="descclassname">CGIXMLRPCRequestHandler.</tt><tt class="descname">handle_request</tt><big>(</big><em>request_text=None</em><big>)</big><a class="headerlink" href="#xmlrpc.server.CGIXMLRPCRequestHandler.handle_request" title="Permalink to this definition">¶</a></dt>
<dd><p>Handle a XML-RPC request. If <em>request_text</em> is given, it  should be the POST
data provided by the HTTP server,  otherwise the contents of stdin will be used.</p>
</dd></dl>

<p>Example:</p>
<div class="highlight-python3"><div class="highlight"><pre><span class="k">class</span> <span class="nc">MyFuncs</span><span class="p">:</span>
    <span class="k">def</span> <span class="nf">mul</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">x</span> <span class="o">*</span> <span class="n">y</span>


<span class="n">handler</span> <span class="o">=</span> <span class="n">CGIXMLRPCRequestHandler</span><span class="p">()</span>
<span class="n">handler</span><span class="o">.</span><span class="n">register_function</span><span class="p">(</span><span class="nb">pow</span><span class="p">)</span>
<span class="n">handler</span><span class="o">.</span><span class="n">register_function</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">:</span> <span class="n">x</span><span class="o">+</span><span class="n">y</span><span class="p">,</span> <span class="s">&#39;add&#39;</span><span class="p">)</span>
<span class="n">handler</span><span class="o">.</span><span class="n">register_introspection_functions</span><span class="p">()</span>
<span class="n">handler</span><span class="o">.</span><span class="n">register_instance</span><span class="p">(</span><span class="n">MyFuncs</span><span class="p">())</span>
<span class="n">handler</span><span class="o">.</span><span class="n">handle_request</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="documenting-xmlrpc-server">
<h2>20.24.3. Documenting XMLRPC server<a class="headerlink" href="#documenting-xmlrpc-server" title="Permalink to this headline">¶</a></h2>
<p>These classes extend the above classes to serve HTML documentation in response
to HTTP GET requests.  Servers can either be free standing, using
<a class="reference internal" href="#xmlrpc.server.DocXMLRPCServer" title="xmlrpc.server.DocXMLRPCServer"><tt class="xref py py-class docutils literal"><span class="pre">DocXMLRPCServer</span></tt></a>, or embedded in a CGI environment, using
<a class="reference internal" href="#xmlrpc.server.DocCGIXMLRPCRequestHandler" title="xmlrpc.server.DocCGIXMLRPCRequestHandler"><tt class="xref py py-class docutils literal"><span class="pre">DocCGIXMLRPCRequestHandler</span></tt></a>.</p>
<dl class="class">
<dt id="xmlrpc.server.DocXMLRPCServer">
<em class="property">class </em><tt class="descclassname">xmlrpc.server.</tt><tt class="descname">DocXMLRPCServer</tt><big>(</big><em>addr</em>, <em>requestHandler=DocXMLRPCRequestHandler</em>, <em>logRequests=True</em>, <em>allow_none=False</em>, <em>encoding=None</em>, <em>bind_and_activate=True</em><big>)</big><a class="headerlink" href="#xmlrpc.server.DocXMLRPCServer" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new server instance. All parameters have the same meaning as for
<a class="reference internal" href="#xmlrpc.server.SimpleXMLRPCServer" title="xmlrpc.server.SimpleXMLRPCServer"><tt class="xref py py-class docutils literal"><span class="pre">SimpleXMLRPCServer</span></tt></a>; <em>requestHandler</em> defaults to
<a class="reference internal" href="#xmlrpc.server.DocXMLRPCRequestHandler" title="xmlrpc.server.DocXMLRPCRequestHandler"><tt class="xref py py-class docutils literal"><span class="pre">DocXMLRPCRequestHandler</span></tt></a>.</p>
</dd></dl>

<dl class="class">
<dt id="xmlrpc.server.DocCGIXMLRPCRequestHandler">
<em class="property">class </em><tt class="descclassname">xmlrpc.server.</tt><tt class="descname">DocCGIXMLRPCRequestHandler</tt><a class="headerlink" href="#xmlrpc.server.DocCGIXMLRPCRequestHandler" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new instance to handle XML-RPC requests in a CGI environment.</p>
</dd></dl>

<dl class="class">
<dt id="xmlrpc.server.DocXMLRPCRequestHandler">
<em class="property">class </em><tt class="descclassname">xmlrpc.server.</tt><tt class="descname">DocXMLRPCRequestHandler</tt><a class="headerlink" href="#xmlrpc.server.DocXMLRPCRequestHandler" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new request handler instance. This request handler supports XML-RPC
POST requests, documentation GET requests, and modifies logging so that the
<em>logRequests</em> parameter to the <a class="reference internal" href="#xmlrpc.server.DocXMLRPCServer" title="xmlrpc.server.DocXMLRPCServer"><tt class="xref py py-class docutils literal"><span class="pre">DocXMLRPCServer</span></tt></a> constructor parameter is
honored.</p>
</dd></dl>

</div>
<div class="section" id="docxmlrpcserver-objects">
<span id="doc-xmlrpc-servers"></span><h2>20.24.4. DocXMLRPCServer Objects<a class="headerlink" href="#docxmlrpcserver-objects" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference internal" href="#xmlrpc.server.DocXMLRPCServer" title="xmlrpc.server.DocXMLRPCServer"><tt class="xref py py-class docutils literal"><span class="pre">DocXMLRPCServer</span></tt></a> class is derived from <a class="reference internal" href="#xmlrpc.server.SimpleXMLRPCServer" title="xmlrpc.server.SimpleXMLRPCServer"><tt class="xref py py-class docutils literal"><span class="pre">SimpleXMLRPCServer</span></tt></a>
and provides a means of creating self-documenting, stand alone XML-RPC
servers. HTTP POST requests are handled as XML-RPC method calls. HTTP GET
requests are handled by generating pydoc-style HTML documentation. This allows a
server to provide its own web-based documentation.</p>
<dl class="method">
<dt id="xmlrpc.server.DocXMLRPCServer.set_server_title">
<tt class="descclassname">DocXMLRPCServer.</tt><tt class="descname">set_server_title</tt><big>(</big><em>server_title</em><big>)</big><a class="headerlink" href="#xmlrpc.server.DocXMLRPCServer.set_server_title" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the title used in the generated HTML documentation. This title will be used
inside the HTML &#8220;title&#8221; element.</p>
</dd></dl>

<dl class="method">
<dt id="xmlrpc.server.DocXMLRPCServer.set_server_name">
<tt class="descclassname">DocXMLRPCServer.</tt><tt class="descname">set_server_name</tt><big>(</big><em>server_name</em><big>)</big><a class="headerlink" href="#xmlrpc.server.DocXMLRPCServer.set_server_name" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the name used in the generated HTML documentation. This name will appear at
the top of the generated documentation inside a &#8220;h1&#8221; element.</p>
</dd></dl>

<dl class="method">
<dt id="xmlrpc.server.DocXMLRPCServer.set_server_documentation">
<tt class="descclassname">DocXMLRPCServer.</tt><tt class="descname">set_server_documentation</tt><big>(</big><em>server_documentation</em><big>)</big><a class="headerlink" href="#xmlrpc.server.DocXMLRPCServer.set_server_documentation" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the description used in the generated HTML documentation. This description
will appear as a paragraph, below the server name, in the documentation.</p>
</dd></dl>

</div>
<div class="section" id="doccgixmlrpcrequesthandler">
<h2>20.24.5. DocCGIXMLRPCRequestHandler<a class="headerlink" href="#doccgixmlrpcrequesthandler" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference internal" href="#xmlrpc.server.DocCGIXMLRPCRequestHandler" title="xmlrpc.server.DocCGIXMLRPCRequestHandler"><tt class="xref py py-class docutils literal"><span class="pre">DocCGIXMLRPCRequestHandler</span></tt></a> class is derived from
<a class="reference internal" href="#xmlrpc.server.CGIXMLRPCRequestHandler" title="xmlrpc.server.CGIXMLRPCRequestHandler"><tt class="xref py py-class docutils literal"><span class="pre">CGIXMLRPCRequestHandler</span></tt></a> and provides a means of creating
self-documenting, XML-RPC CGI scripts. HTTP POST requests are handled as XML-RPC
method calls. HTTP GET requests are handled by generating pydoc-style HTML
documentation. This allows a server to provide its own web-based documentation.</p>
<dl class="method">
<dt id="xmlrpc.server.DocCGIXMLRPCRequestHandler.set_server_title">
<tt class="descclassname">DocCGIXMLRPCRequestHandler.</tt><tt class="descname">set_server_title</tt><big>(</big><em>server_title</em><big>)</big><a class="headerlink" href="#xmlrpc.server.DocCGIXMLRPCRequestHandler.set_server_title" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the title used in the generated HTML documentation. This title will be used
inside the HTML &#8220;title&#8221; element.</p>
</dd></dl>

<dl class="method">
<dt id="xmlrpc.server.DocCGIXMLRPCRequestHandler.set_server_name">
<tt class="descclassname">DocCGIXMLRPCRequestHandler.</tt><tt class="descname">set_server_name</tt><big>(</big><em>server_name</em><big>)</big><a class="headerlink" href="#xmlrpc.server.DocCGIXMLRPCRequestHandler.set_server_name" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the name used in the generated HTML documentation. This name will appear at
the top of the generated documentation inside a &#8220;h1&#8221; element.</p>
</dd></dl>

<dl class="method">
<dt id="xmlrpc.server.DocCGIXMLRPCRequestHandler.set_server_documentation">
<tt class="descclassname">DocCGIXMLRPCRequestHandler.</tt><tt class="descname">set_server_documentation</tt><big>(</big><em>server_documentation</em><big>)</big><a class="headerlink" href="#xmlrpc.server.DocCGIXMLRPCRequestHandler.set_server_documentation" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the description used in the generated HTML documentation. This description
will appear as a paragraph, below the server name, in the documentation.</p>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">20.24. <tt class="docutils literal"><span class="pre">xmlrpc.server</span></tt> &#8212; Basic XML-RPC servers</a><ul>
<li><a class="reference internal" href="#simplexmlrpcserver-objects">20.24.1. SimpleXMLRPCServer Objects</a><ul>
<li><a class="reference internal" href="#simplexmlrpcserver-example">20.24.1.1. SimpleXMLRPCServer Example</a></li>
</ul>
</li>
<li><a class="reference internal" href="#cgixmlrpcrequesthandler">20.24.2. CGIXMLRPCRequestHandler</a></li>
<li><a class="reference internal" href="#documenting-xmlrpc-server">20.24.3. Documenting XMLRPC server</a></li>
<li><a class="reference internal" href="#docxmlrpcserver-objects">20.24.4. DocXMLRPCServer Objects</a></li>
<li><a class="reference internal" href="#doccgixmlrpcrequesthandler">20.24.5. DocCGIXMLRPCRequestHandler</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="xmlrpc.client.html"
                        title="previous chapter">20.23. <tt class="docutils literal docutils literal docutils literal"><span class="pre">xmlrpc.client</span></tt> &#8212; XML-RPC client access</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="mm.html"
                        title="next chapter">21. Multimedia Services</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
  <li><a href="../bugs.html">Report a Bug</a></li>
  <li><a href="../_sources/library/xmlrpc.server.txt"
         rel="nofollow">Show Source</a></li>
</ul>

<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="mm.html" title="21. Multimedia Services"
             >next</a> |</li>
        <li class="right" >
          <a href="xmlrpc.client.html" title="20.23. xmlrpc.client — XML-RPC client access"
             >previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="../index.html">Python v3.2.2 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="internet.html" >20. Internet Protocols and Support</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 1990-2011, Python Software Foundation.
    <br />
    The Python Software Foundation is a non-profit corporation.  
    <a href="http://www.python.org/psf/donations/">Please donate.</a>
    <br />
    Last updated on Sep 04, 2011.
    <a href="../bugs.html">Found a bug</a>?
    <br />
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
    </div>

  </body>
</html>