;
"Ic               @   s  d  Z  d d l m Z m Z m Z d d l m Z d d l Z d d l Z d d l	 Z	 d d l
 Z
 d d l Z d d l Z d d l Z d d l Z y d d l Z Wn e k
 o e Z Yn Xe d  Z d   Z Gd   d  Z Gd	   d
 e  Z Gd   d e j e  Z Gd   d e  Z Gd   d e j  Z Gd   d  Z Gd   d e  Z Gd   d e e  Z Gd   d e e  Z e  d k oJ e! d  e d d f  Z" e" j# e$  e" j# d   d  e" j%   n d S(   u  XML-RPC Servers.

This module can be used to create simple XML-RPC servers
by creating a server and either installing functions, a
class instance, or by extending the SimpleXMLRPCServer
class.

It can also be used to handle XML-RPC requests in a CGI
environment using CGIXMLRPCRequestHandler.

The Doc* classes can be used to create XML-RPC servers that
serve pydoc-style documentation in response to HTTP
GET requests. This documentation is dynamically generated
based on the functions and methods registered with the
server.

A list of possible usage patterns follows:

1. Install functions:

server = SimpleXMLRPCServer(("localhost", 8000))
server.register_function(pow)
server.register_function(lambda x,y: x+y, 'add')
server.serve_forever()

2. Install an instance:

class MyFuncs:
    def __init__(self):
        # make all of the sys functions available through sys.func_name
        import sys
        self.sys = sys
    def _listMethods(self):
        # implement this method so that system.listMethods
        # knows to advertise the sys methods
        return list_public_methods(self) +                 ['sys.' + method for method in list_public_methods(self.sys)]
    def pow(self, x, y): return pow(x, y)
    def add(self, x, y) : return x + y

server = SimpleXMLRPCServer(("localhost", 8000))
server.register_introspection_functions()
server.register_instance(MyFuncs())
server.serve_forever()

3. Install an instance with custom dispatch method:

class Math:
    def _listMethods(self):
        # this method must be present for system.listMethods
        # to work
        return ['add', 'pow']
    def _methodHelp(self, method):
        # this method must be present for system.methodHelp
        # to work
        if method == 'add':
            return "add(2,3) => 5"
        elif method == 'pow':
            return "pow(x, y[, z]) => number"
        else:
            # By convention, return empty
            # string if no help is available
            return ""
    def _dispatch(self, method, params):
        if method == 'pow':
            return pow(*params)
        elif method == 'add':
            return params[0] + params[1]
        else:
            raise 'bad method'

server = SimpleXMLRPCServer(("localhost", 8000))
server.register_introspection_functions()
server.register_instance(Math())
server.serve_forever()

4. Subclass SimpleXMLRPCServer:

class MathServer(SimpleXMLRPCServer):
    def _dispatch(self, method, params):
        try:
            # We are forcing the 'export_' prefix on methods that are
            # callable through XML-RPC to prevent potential security
            # problems
            func = getattr(self, 'export_' + method)
        except AttributeError:
            raise Exception('method "%s" is not supported' % method)
        else:
            return func(*params)

    def export_add(self, x, y):
        return x + y

server = MathServer(("localhost", 8000))
server.serve_forever()

5. CGI script:

server = CGIXMLRPCRequestHandler()
server.register_function(pow)
server.handle_request()
i    (   u   Faultu   dumpsu   loads(   u   BaseHTTPRequestHandlerNc             C   sk   | o | j  d  } n
 | g } xA | D]9 } | j d  o t d |   q* t |  |  }  q* W|  S(   uG  resolve_dotted_attribute(a, 'b.c.d') => a.b.c.d

    Resolves a dotted attribute name to an object.  Raises
    an AttributeError if any attribute in the chain starts with a '_'.

    If the optional allow_dotted_names argument is false, dots are not
    supported and this function operates similar to getattr(obj, attr).
    u   .u   _u(   attempt to access private attribute "%s"(   u   splitu
   startswithu   AttributeErroru   getattr(   u   obju   attru   allow_dotted_namesu   attrsu   i(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   resolve_dotted_attributez   s    
	 c                s     f d   t     D S(   uk   Returns a list of attribute strings, found in the specified
    object, which represent callable attributesc                sI   g  } |  ]; } | j  d   o$ t t   |  d  o | | q
 q
 S(   u   _u   __call__(   u
   startswithu   hasattru   getattr(   u   .0u   _[1]u   member(   u   obj(    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu
   <listcomp>   s    (   u   dir(   u   obj(    (   u   obju*   /mit/python/lib/python3.0/xmlrpc/server.pyu   list_public_methods   s    c             B   s   |  Ee  Z d  Z d   Z d d  Z d d  Z d   Z d   Z	 d d  Z
 d   Z d   Z d	   Z d
   Z d   Z d S(   u   Mix-in class that dispatches XML-RPC requests.

    This class is used to register XML-RPC method handlers
    and then to dispatch them. There should never be any
    reason to instantiate this class directly.
    c             C   s(   i  |  _  d  |  _ | |  _ | |  _ d  S(   N(   u   funcsu   Noneu   instanceu
   allow_noneu   encoding(   u   selfu
   allow_noneu   encoding(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   __init__   s    			c             C   s   | |  _  | |  _ d S(   u  Registers an instance to respond to XML-RPC requests.

        Only one instance can be installed at a time.

        If the registered instance has a _dispatch method then that
        method will be called with the name of the XML-RPC method and
        its parameters as a tuple
        e.g. instance._dispatch('add',(2,3))

        If the registered instance does not have a _dispatch method
        then the instance will be searched to find a matching method
        and, if found, will be called. Methods beginning with an '_'
        are considered private and will not be called by
        SimpleXMLRPCServer.

        If a registered function matches a XML-RPC request, then it
        will be called instead of the registered instance.

        If the optional allow_dotted_names argument is true and the
        instance does not have a _dispatch method, method names
        containing dots are supported and resolved, as long as none of
        the name segments start with an '_'.

            *** SECURITY WARNING: ***

            Enabling the allow_dotted_names options allows intruders
            to access your module's global variables and may allow
            intruders to execute arbitrary code on your machine.  Only
            use this option on a secure, closed network.

        N(   u   instanceu   allow_dotted_names(   u   selfu   instanceu   allow_dotted_names(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   register_instance   s    !	c             C   s+   | d k o | j } n | |  j | <d S(   u   Registers a function to respond to XML-RPC requests.

        The optional name argument can be used to set a Unicode name
        for the function.
        N(   u   Noneu   __name__u   funcs(   u   selfu   functionu   name(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   register_function   s    c             C   s2   |  j  j i |  j d 6|  j d 6|  j d 6 d S(   u   Registers the XML-RPC introspection methods in the system
        namespace.

        see http://xmlrpc.usefulinc.com/doc/reserved.html
        u   system.listMethodsu   system.methodSignatureu   system.methodHelpN(   u   funcsu   updateu   system_listMethodsu   system_methodSignatureu   system_methodHelp(   u   self(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu    register_introspection_functions   s    
c             C   s   |  j  j i |  j d 6 d S(   u   Registers the XML-RPC multicall method in the system
        namespace.

        see http://www.xmlrpc.com/discuss/msgReader$1208u   system.multicallN(   u   funcsu   updateu   system_multicall(   u   self(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   register_multicall_functions   s    c       
      C   s  yu t  |  \ } } | d k	 o | | |  } n |  j | |  } | f } t | d d d |  j d |  j } Wn t k
 o9 } z# t | d |  j d |  j } WYd d } ~ XnO t j   \ } } }	 t t d d | | f  d |  j d |  j } Yn X| S(   u  Dispatches an XML-RPC method from marshalled (XML) data.

        XML-RPC methods are dispatched from the marshalled (XML) data
        using the _dispatch method and the result is returned as
        marshalled data. For backwards compatibility, a dispatch
        function can be provided as an argument (see comment in
        SimpleXMLRPCRequestHandler.do_POST) but overriding the
        existing method through subclassing is the prefered means
        of changing method dispatch behavior.
        u   methodresponsei   u
   allow_noneu   encodingNu   %s:%s(	   u   loadsu   Noneu	   _dispatchu   dumpsu
   allow_noneu   encodingu   Faultu   sysu   exc_info(
   u   selfu   datau   dispatch_methodu   paramsu   methodu   responseu   faultu   exc_typeu	   exc_valueu   exc_tb(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   _marshaled_dispatch   s"    	c             C   s   t  |  j j    } |  j d k	 od t |  j d  o | t  |  j j    O} q t |  j d  p | t  t |  j   O} q n t |  S(   uw   system.listMethods() => ['add', 'subtract', 'multiple']

        Returns a list of the methods supported by the server.u   _listMethodsu	   _dispatchN(	   u   setu   funcsu   keysu   instanceu   Noneu   hasattru   _listMethodsu   list_public_methodsu   sorted(   u   selfu   methods(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   system_listMethods  s    !c             C   s   d S(   u#  system.methodSignature('add') => [double, int, int]

        Returns a list describing the signature of the method. In the
        above example, the add method takes two integers as arguments
        and returns a double result.

        This server does NOT support system.methodSignature.u   signatures not supported(    (   u   selfu   method_name(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   system_methodSignature!  s    c          
   C   s   d } | |  j k o |  j | } n |  j d k	 or t |  j d  o |  j j |  St |  j d  p7 y t |  j | |  j  } Wq t k
 o Yq Xq n | d k o d Sd d l } | j	 |  Sd S(   u   system.methodHelp('add') => "Adds two integers together"

        Returns a string containing documentation for the specified method.u   _methodHelpu	   _dispatchu    i    N(
   u   Noneu   funcsu   instanceu   hasattru   _methodHelpu   resolve_dotted_attributeu   allow_dotted_namesu   AttributeErroru   pydocu   getdoc(   u   selfu   method_nameu   methodu   pydoc(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   system_methodHelp.  s$    c       
      C   s   g  } x | D] } | d } | d } y  | j  |  j | |  g  Wq t k
 o< } z& | j  i | j d 6| j d 6 WYd d } ~ Xq t j   \ } } }	 | j  i d d 6d | | f d 6 Yq Xq W| S(   u   system.multicall([{'methodName': 'add', 'params': [2, 2]}, ...]) => [[4], ...]

        Allows the caller to package multiple XML-RPC calls into a single
        request.

        See http://www.xmlrpc.com/discuss/msgReader$1208
        u
   methodNameu   paramsu	   faultCodeu   faultStringNi   u   %s:%s(   u   appendu	   _dispatchu   Faultu	   faultCodeu   faultStringu   sysu   exc_info(
   u   selfu	   call_listu   resultsu   callu   method_nameu   paramsu   faultu   exc_typeu	   exc_valueu   exc_tb(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   system_multicallN  s"    
 

 !
c             C   s   d } y |  j | } Wn t k
 ov |  j d k	 o^ t |  j d  o |  j j | |  Sy t |  j | |  j  } Wq t k
 o Yq Xn Yn X| d k	 o | |   St	 d |   d S(   u  Dispatches the XML-RPC method.

        XML-RPC calls are forwarded to a registered function that
        matches the called XML-RPC method name. If no such function
        exists then the call is forwarded to the registered instance,
        if available.

        If the registered instance has a _dispatch method then that
        method will be called with the name of the XML-RPC method and
        its parameters as a tuple
        e.g. instance._dispatch('add',(2,3))

        If the registered instance does not have a _dispatch method
        then the instance will be searched to find a matching method
        and, if found, will be called.

        Methods beginning with an '_' are considered private and will
        not be called.
        u	   _dispatchu   method "%s" is not supportedN(
   u   Noneu   funcsu   KeyErroru   instanceu   hasattru	   _dispatchu   resolve_dotted_attributeu   allow_dotted_namesu   AttributeErroru	   Exception(   u   selfu   methodu   paramsu   func(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu	   _dispatchn  s"    NF(   u   __name__u
   __module__u   __doc__u   __init__u   Falseu   register_instanceu   Noneu   register_functionu    register_introspection_functionsu   register_multicall_functionsu   _marshaled_dispatchu   system_listMethodsu   system_methodSignatureu   system_methodHelpu   system_multicallu	   _dispatch(   u
   __locals__(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   SimpleXMLRPCDispatcher   s   
	$		%			 	 u   SimpleXMLRPCDispatcherc             B   sD   |  Ee  Z d  Z d	 Z d   Z d   Z d   Z d d d  Z d S(
   u   Simple XML-RPC request handler class.

    Handles all HTTP POST requests and attempts to decode them as
    XML-RPC requests.
    u   /u   /RPC2c             C   s#   |  j  o |  j |  j  k Sd Sd  S(   NT(   u	   rpc_pathsu   pathu   True(   u   self(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   is_rpc_path_valid  s    
c             C   s  |  j    p |  j   d Sy d } t |  j d  } g  } xH | o@ t | |  } | j |  j j |   | t | d  8} qA Wd j	 |  } |  j
 j | t |  d d   } Wn t k
 o } zl |  j d  t |  j
 d	  o= |  j
 j o0 |  j d
 t |   |  j d t j    n |  j   WYd d } ~ Xn X| j d  } |  j d  |  j d d  |  j d t t |    |  j   |  j j |  |  j j   |  j j d  d S(   u   Handles the HTTP POST request.

        Attempts to interpret all HTTP POST requests as XML-RPC calls,
        which are forwarded to the server's _dispatch method for handling.
        Ni
   i   u   content-lengthis    u	   _dispatchi  u   _send_traceback_headeru   X-exceptionu   X-tracebacku   utf-8i   u   Content-typeu   text/xmlu   Content-lengthi   i (  i   (   u   is_rpc_path_validu
   report_404u   intu   headersu   minu   appendu   rfileu   readu   lenu   joinu   serveru   _marshaled_dispatchu   getattru   Noneu	   Exceptionu   send_responseu   hasattru   _send_traceback_headeru   send_headeru   stru	   tracebacku
   format_excu   end_headersu   encodeu   wfileu   writeu   flushu
   connectionu   shutdown(   u   selfu   max_chunk_sizeu   size_remainingu   Lu
   chunk_sizeu   datau   responseu   e(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   do_POST  s<    
 	
c             C   sz   |  j  d  d } |  j d d  |  j d t t |    |  j   |  j j |  |  j j   |  j j	 d  d  S(   Ni  s   No such pageu   Content-typeu
   text/plainu   Content-lengthi   (
   u   send_responseu   send_headeru   stru   lenu   end_headersu   wfileu   writeu   flushu
   connectionu   shutdown(   u   selfu   response(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu
   report_404  s    
u   -c             C   s(   |  j  j o t j |  | |  n d S(   u$   Selectively log an accepted request.N(   u   serveru   logRequestsu   BaseHTTPRequestHandleru   log_request(   u   selfu   codeu   size(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   log_request  s    N(   u   /u   /RPC2(   u   __name__u
   __module__u   __doc__u	   rpc_pathsu   is_rpc_path_validu   do_POSTu
   report_404u   log_request(   u
   __locals__(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   SimpleXMLRPCRequestHandler  s   
		:	u   SimpleXMLRPCRequestHandlerc             B   s8   |  Ee  Z d  Z d Z d Z e d d d d d  Z	 d S(   ug  Simple XML-RPC server.

    Simple XML-RPC server that allows functions and a single instance
    to be installed to handle requests. The default implementation
    attempts to dispatch XML-RPC calls to the functions or instance
    installed in the server. Override the _dispatch method inhereted
    from SimpleXMLRPCDispatcher to change this behavior.
    c             C   s   | |  _  t j |  | |  t j j |  | | |  t d  k	 oX t t d  oH t j |  j   t j	  } | t j
 O} t j |  j   t j |  n d  S(   Nu
   FD_CLOEXEC(   u   logRequestsu   SimpleXMLRPCDispatcheru   __init__u   socketserveru	   TCPServeru   fcntlu   Noneu   hasattru   filenou   F_GETFDu
   FD_CLOEXECu   F_SETFD(   u   selfu   addru   requestHandleru   logRequestsu
   allow_noneu   encodingu   bind_and_activateu   flags(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   __init__  s    	NTF(
   u   __name__u
   __module__u   __doc__u   Trueu   allow_reuse_addressu   Falseu   _send_traceback_headeru   SimpleXMLRPCRequestHandleru   Noneu   __init__(   u
   __locals__(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   SimpleXMLRPCServer  s
   
	u   SimpleXMLRPCServerc             B   sA   |  Ee  Z d  Z d d d  Z d   Z d   Z d d  Z d S(   u3   Simple handler for XML-RPC data passed through CGI.c             C   s   t  j |  | |  d  S(   N(   u   SimpleXMLRPCDispatcheru   __init__(   u   selfu
   allow_noneu   encoding(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   __init__  s    c             C   sH   |  j  |  } t d  t d t |   t   t j j |  d S(   u   Handle a single XML-RPC requestu   Content-Type: text/xmlu   Content-Length: %dN(   u   _marshaled_dispatchu   printu   lenu   sysu   stdoutu   write(   u   selfu   request_textu   response(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   handle_xmlrpc"  s
    
c             C   s   d } t  j | \ } } t j j i | d 6| d 6| d 6} t d | | f  t d  t d t |   t   t j j	 |  d S(	   u   Handle a single HTTP GET request.

        Default implementation indicates an error because
        XML-RPC uses the POST method.
        i  u   codeu   messageu   explainu   Status: %d %su   Content-Type: text/htmlu   Content-Length: %dN(
   u   BaseHTTPRequestHandleru	   responsesu   httpu   serveru   DEFAULT_ERROR_MESSAGEu   printu   lenu   sysu   stdoutu   write(   u   selfu   codeu   messageu   explainu   response(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu
   handle_get,  s    	
c             C   sh   | d k o* t j j d d  d k o |  j   n. | d k o t j j   } n |  j |  d S(   u   Handle a single XML-RPC request passed through a CGI post method.

        If no XML data is given then it is read from stdin. The resulting
        XML-RPC response is printed to stdout along with the correct HTTP
        headers.
        u   REQUEST_METHODu   GETN(	   u   Noneu   osu   environu   getu
   handle_getu   sysu   stdinu   readu   handle_xmlrpc(   u   selfu   request_text(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   handle_requestB  s    NF(	   u   __name__u
   __module__u   __doc__u   Falseu   Noneu   __init__u   handle_xmlrpcu
   handle_getu   handle_request(   u
   __locals__(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   CGIXMLRPCRequestHandler  s
   
	
	u   CGIXMLRPCRequestHandlerc             B   sJ   |  Ee  Z d  Z d i  i  i  d  Z d i  i  i  d d  Z d   Z d S(   u7   Class used to generate pydoc HTML document for a serverc             C   s  | p |  j  } g  } d } t j d  } x| j | |  }	 |	 p Pn |	 j   \ }
 } | j | | | |
    |	 j   \ } } } } } } | o3 | |  j d d  } | j d | | f  n | o1 d t |  } | j d | | |  f  n | o1 d t |  } | j d | | |  f  nt | | | d  d	 k o# | j |  j	 | | | |   n6 | o | j d
 |  n | j |  j	 | |   | } q. | j | | | d    d j
 |  S(   u   Mark up some plain text, given a context of symbols to look for.
        Each context dictionary maps object names to anchor names.i    uM   \b((http|ftp)://\S+[\w/]|RFC[- ]?(\d+)|PEP[- ]?(\d+)|(self\.)?((?:\w|\.)+))\bu   "u   &quot;u   <a href="%s">%s</a>u'   http://www.rfc-editor.org/rfc/rfc%d.txtu(   http://www.python.org/dev/peps/pep-%04d/i   u   (u   self.<strong>%s</strong>Nu    (   u   escapeu   reu   compileu   searchu   spanu   appendu   groupsu   replaceu   intu   namelinku   join(   u   selfu   textu   escapeu   funcsu   classesu   methodsu   resultsu   hereu   patternu   matchu   startu   endu   allu   schemeu   rfcu   pepu   selfdotu   nameu   url(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   markup[  s8     !!#	c             C   s  | o
 | j  p d d | } d }	 d |  j |  |  j |  f }
 t j |  oJ t j |  \ } } } } t j | d d  | | | d |  j } nW t j |  o@ t j |  \ } } } } t j | | | | d |  j } n d } t | t	  o& | d p | } | d p d } n t
 j |  } |
 | |	 o |  j d	 |	  } |  j | |  j | | |  } | o d
 | } d | | f S(   u;   Produce HTML documentation for a function or method object.u    u   -u$   <a name="%s"><strong>%s</strong></a>i   Nu   formatvalueu   (...)i    u'   <font face="helvetica, arial">%s</font>u   <dd><tt>%s</tt></dd>u   <dl><dt>%s</dt>%s</dl>
(   u   __name__u   escapeu   inspectu   ismethodu
   getargspecu   formatargspecu   formatvalueu
   isfunctionu
   isinstanceu   tupleu   pydocu   getdocu   greyu   markupu	   preformat(   u   selfu   objectu   nameu   modu   funcsu   classesu   methodsu   clu   anchoru   noteu   titleu   argsu   varargsu   varkwu   defaultsu   argspecu	   docstringu   declu   doc(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu
   docroutine  s6    c             C   s  i  } x6 | j    D]( \ } } d | | | <| | | | <q W|  j |  } d | } |  j | d d  } |  j | |  j |  }	 |	 o d |	 }	 | d |	 } g  }
 t | j     } x3 | D]+ \ } } |
 j |  j | | d |  q W| |  j d d d	 d
 j	 |
   } | S(   u1   Produce HTML documentation for an XML-RPC server.u   #-u)   <big><big><strong>%s</strong></big></big>u   #ffffffu   #7799eeu   <tt>%s</tt>u
   <p>%s</p>
u   funcsu   Methodsu   #eeaa77u    (
   u   itemsu   escapeu   headingu   markupu	   preformatu   sortedu   appendu
   docroutineu
   bigsectionu   join(   u   selfu   server_nameu   package_documentationu   methodsu   fdictu   keyu   valueu   headu   resultu   docu   contentsu   method_items(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu	   docserver  s&     
 #	N(   u   __name__u
   __module__u   __doc__u   Noneu   markupu
   docroutineu	   docserver(   u
   __locals__(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   ServerHTMLDocX  s
   
))u   ServerHTMLDocc             B   sA   |  Ee  Z d  Z d   Z d   Z d   Z d   Z d   Z d S(   u   Generates documentation for an XML-RPC server.

    This class is designed as mix-in and should not
    be constructed directly.
    c             C   s   d |  _  d |  _ d |  _ d  S(   Nu   XML-RPC Server DocumentationuG   This server exports the following methods through the XML-RPC protocol.(   u   server_nameu   server_documentationu   server_title(   u   self(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   __init__  s    		c             C   s   | |  _  d S(   u8   Set the HTML title of the generated server documentationN(   u   server_title(   u   selfu   server_title(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   set_server_title  s    c             C   s   | |  _  d S(   u7   Set the name of the generated HTML server documentationN(   u   server_name(   u   selfu   server_name(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   set_server_name  s    c             C   s   | |  _  d S(   u3   Set the documentation string for the entire server.N(   u   server_documentation(   u   selfu   server_documentation(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   set_server_documentation  s    c          
   C   sl  i  } x,|  j    D]} | |  j k o |  j | } n |  j d k	 o d d g } t |  j d  o |  j j |  | d <n t |  j d  o |  j j |  | d <n t |  } | d k o
 | } q't |  j d  p7 y t |  j |  } Wq#t	 k
 o | } Yq#Xq'| } n | | | <q Wt
   } | j |  j |  j |  } | j |  j |  S(   u  generate_html_documentation() => html documentation for the server

        Generates HTML documentation for the server using introspection for
        installed functions and instances that do not implement the
        _dispatch method. Alternatively, instances can choose to implement
        the _get_method_argstring(method_name) method to provide the
        argument string used in the documentation and the
        _methodHelp(method_name) method to provide the help text used
        in the documentation.u   _get_method_argstringi    u   _methodHelpi   u	   _dispatchN(   NN(   u   system_listMethodsu   funcsu   instanceu   Noneu   hasattru   _get_method_argstringu   _methodHelpu   tupleu   resolve_dotted_attributeu   AttributeErroru   ServerHTMLDocu	   docserveru   server_nameu   server_documentationu   pageu   server_title(   u   selfu   methodsu   method_nameu   methodu   method_infou
   documenteru   documentation(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   generate_html_documentation  s:     

		N(   u   __name__u
   __module__u   __doc__u   __init__u   set_server_titleu   set_server_nameu   set_server_documentationu   generate_html_documentation(   u
   __locals__(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   XMLRPCDocGenerator  s   
				u   XMLRPCDocGeneratorc             B   s   |  Ee  Z d  Z d   Z d S(   u   XML-RPC and documentation request handler class.

    Handles all HTTP POST requests and attempts to decode them as
    XML-RPC requests.

    Handles all HTTP GET requests and interprets them as requests
    for documentation.
    c             C   s   |  j    p |  j   d S|  j j   } |  j d  |  j d d  |  j d t t |    |  j   |  j	 j
 | j    |  j	 j   |  j j d  d S(   u}   Handles the HTTP GET request.

        Interpret all HTTP GET requests as requests for server
        documentation.
        Ni   u   Content-typeu	   text/htmlu   Content-lengthi   (   u   is_rpc_path_validu
   report_404u   serveru   generate_html_documentationu   send_responseu   send_headeru   stru   lenu   end_headersu   wfileu   writeu   encodeu   flushu
   connectionu   shutdown(   u   selfu   response(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   do_GET"  s    

N(   u   __name__u
   __module__u   __doc__u   do_GET(   u
   __locals__(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   DocXMLRPCRequestHandler  s   
u   DocXMLRPCRequestHandlerc             B   s,   |  Ee  Z d  Z e d d d d d  Z d S(   u   XML-RPC and HTML documentation server.

    Adds the ability to serve server documentation to the capabilities
    of SimpleXMLRPCServer.
    i   c             C   s0   t  j |  | | | | | |  t j |   d  S(   N(   u   SimpleXMLRPCServeru   __init__u   XMLRPCDocGenerator(   u   selfu   addru   requestHandleru   logRequestsu
   allow_noneu   encodingu   bind_and_activate(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   __init__@  s    NFT(   u   __name__u
   __module__u   __doc__u   DocXMLRPCRequestHandleru   Falseu   Noneu   Trueu   __init__(   u
   __locals__(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   DocXMLRPCServer8  s   
	u   DocXMLRPCServerc             B   s&   |  Ee  Z d  Z d   Z d   Z d S(   uJ   Handler for XML-RPC data and documentation requests passed through
    CGIc             C   sE   |  j    } t d  t d t |   t   t j j |  d S(   u}   Handles the HTTP GET request.

        Interpret all HTTP GET requests as requests for server
        documentation.
        u   Content-Type: text/htmlu   Content-Length: %dN(   u   generate_html_documentationu   printu   lenu   sysu   stdoutu   write(   u   selfu   response(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu
   handle_getL  s
    
c             C   s   t  j |   t j |   d  S(   N(   u   CGIXMLRPCRequestHandleru   __init__u   XMLRPCDocGenerator(   u   self(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   __init__Z  s    N(   u   __name__u
   __module__u   __doc__u
   handle_getu   __init__(   u
   __locals__(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   DocCGIXMLRPCRequestHandlerG  s   
	u   DocCGIXMLRPCRequestHandleru   __main__u#   Running XML-RPC server on port 8000u	   localhosti@  c             C   s   |  | S(    (    (   u   xu   y(    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   <lambda>c  s    u   add(&   u   __doc__u   xmlrpc.clientu   Faultu   dumpsu   loadsu   http.serveru   BaseHTTPRequestHandleru   httpu   socketserveru   sysu   osu   reu   pydocu   inspectu	   tracebacku   fcntlu   ImportErroru   Noneu   Trueu   resolve_dotted_attributeu   list_public_methodsu   SimpleXMLRPCDispatcheru   SimpleXMLRPCRequestHandleru	   TCPServeru   SimpleXMLRPCServeru   CGIXMLRPCRequestHandleru   HTMLDocu   ServerHTMLDocu   XMLRPCDocGeneratoru   DocXMLRPCRequestHandleru   DocXMLRPCServeru   DocCGIXMLRPCRequestHandleru   __name__u   printu   serveru   register_functionu   powu   serve_forever(    (    (    u*   /mit/python/lib/python3.0/xmlrpc/server.pyu   <module>f   sF   	 ^	!<oQ 		
