mς %U²Ic@s8dZdkZdkZdkZdkZdkZdklZlZlZl Z dei fd„ƒYZ dfd„ƒYZ defd„ƒYZ d ee fd „ƒYZd ee fd „ƒYZed joad„ZedƒZeidƒeidƒeidƒeieƒeiƒeiƒndS(sKSelf documenting XML-RPC Server. This module 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. This module is built upon the pydoc and SimpleXMLRPCServer modules. N(sSimpleXMLRPCServersSimpleXMLRPCRequestHandlersCGIXMLRPCRequestHandlersresolve_dotted_attributet ServerHTMLDoccBsGtZdZehhhd„Zeehhhed„Zd„ZRS(s7Class used to generate pydoc HTML document for a servercCsί|p|i}g} d} tidƒ}x|i|| ƒ}|pPn|i ƒ\}}| i ||| |!ƒƒ|iƒ\}}} } }}|o3||ƒiddƒ} | i d| | fƒnα| o1dt| ƒ} | i d| ||ƒfƒn©| o1dt| ƒ} | i d| ||ƒfƒnq|||d!d jo#| i |i||||ƒƒn6|o| i d |ƒn| i |i||ƒƒ|} q.W| i ||| ƒƒd i| ƒS( sƒMark up some plain text, given a context of symbols to look for. Each context dictionary maps object names to anchor names.isM\b((http|ftp)://\S+[\w/]|RFC[- ]?(\d+)|PEP[- ]?(\d+)|(self\.)?((?:\w|\.)+))\bit"s"s%ss'http://www.rfc-editor.org/rfc/rfc%d.txts(http://www.python.org/peps/pep-%04d.htmlt(sself.%stN(tescapetselftresultstheretretcompiletpatterntsearchttexttmatchtspantstarttendtappendtgroupstalltschemetrfctpeptselfdottnametreplaceturltinttnamelinktmethodstfuncstclassestjoin(RR RRRRRRRRRRRRR RRR R((t,/data/zmath/lib/python2.4/DocXMLRPCServer.pytmarkups<!!# cCs‰|o |ipdd|}d} d||f} ti|ƒoGti |i ƒ\} }} }ti| d|| |d|iƒ}nWti|ƒo@ti |ƒ\} }} }ti| || |d|iƒ}nd}t|tiƒo&|dp|}|dpd} nti|ƒ} | || o|id| ƒ}|i| |i|||ƒ}|od |}d ||fS( s;Produce HTML documentation for a function or method object.Rt-s$%sit formatvalues(...)is'%ss
%s
s
%s
%s
N("tclt__name__Rtanchortnotettitletinspecttismethodtobjectt getargspectim_functargstvarargstvarkwtdefaultst formatargspecRR$targspect isfunctiont isinstancettypest TupleTypet docstringtpydoctgetdoctgreytdeclR"t preformatRRRtdoc(RR,RtmodRRRR%R=R)R(R1R/R9R0R?R4R2R'((R!t docroutineDs. %"c Csh} x6|iƒD](\} }d| | | <| | | |%ss#ffffffs#7799ees %ss

%s

RtMethodss#eeaa77N(tfdictRtitemstkeytvaluet server_nametheadRtheadingtresultR"tpackage_documentationR>R?tcontentst method_itemstsortRRAt bigsectionR:R ( RRGRKRRHR?RFRMRJRERCRL((R!t docserverms&     #%(R&t __module__t__doc__tNoneR"RARP(((R!Rs ))tXMLRPCDocGeneratorcBs;tZdZd„Zd„Zd„Zd„Zd„ZRS(s…Generates documentation for an XML-RPC server. This class is designed as mix-in and should not be constructed directly. cCsd|_d|_d|_dS(NsXML-RPC Server DocumentationsGThis server exports the following methods through the XML-RPC protocol.(RRGtserver_documentationt server_title(R((R!t__init__s  cCs ||_dS(s8Set the HTML title of the generated server documentationN(RVR(RRV((R!tset_server_title•scCs ||_dS(s7Set the name of the generated HTML server documentationN(RGR(RRG((R!tset_server_namešscCs ||_dS(s3Set the documentation string for the entire server.N(RUR(RRU((R!tset_server_documentationŸscCsnh}x.|iƒD] }|ii|ƒo|i|}nν|idj oάddg}t |idƒo|ii |ƒ|d 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.t_get_method_argstringit _methodHelpit _dispatchN(NN(RRtsystem_listMethodst method_nameRthas_keytmethodtinstanceRSt method_infothasattrR[R\ttupletresolve_dotted_attributetAttributeErrorRt documenterRPRGRUt documentationtpageRV(RRRiRhRaR_Rc((R!tgenerate_html_documentation€s:            (R&RQRRRWRXRYRZRk(((R!RT†s     tDocXMLRPCRequestHandlercBstZdZd„ZRS(sθ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. cCsƒ|iiƒ}|idƒ|iddƒ|idtt|ƒƒƒ|iƒ|i i |ƒ|i i ƒ|i i dƒdS(s}Handles the HTTP GET request. Interpret all HTTP GET requests as requests for server documentation. iΘs Content-types text/htmlsContent-lengthiN(RtserverRktresponset send_responset send_headertstrtlent end_headerstwfiletwritetflusht connectiontshutdown(RRn((R!tdo_GETαs   (R&RQRRRy(((R!RlΧs tDocXMLRPCServercBstZdZedd„ZRS(sŽXML-RPC and HTML documentation server. Adds the ability to serve server documentation to the capabilities of SimpleXMLRPCServer. icCs'ti||||ƒti|ƒdS(N(tSimpleXMLRPCServerRWRtaddrtrequestHandlert logRequestsRT(RR|R}R~((R!RWϋs(R&RQRRRlRW(((R!Rzσs tDocCGIXMLRPCRequestHandlercBs tZdZd„Zd„ZRS(sJHandler for XML-RPC data and documentation requests passed through CGIcCs5|iƒ}dGHdt|ƒGHHtii|ƒdS(s}Handles the HTTP GET request. Interpret all HTTP GET requests as requests for server documentation. sContent-Type: text/htmlsContent-Length: %dN(RRkRnRrtsyststdoutRu(RRn((R!t handle_gets  cCsti|ƒti|ƒdS(N(tCGIXMLRPCRequestHandlerRWRRT(R((R!RWs (R&RQRRR‚RW(((R!Rs  t__main__cCsdk}||idS(sadeg_to_rad(90) => 1.5707963267948966 Converts an angle in degrees to an angle in radiansNi΄(tmathtdegtpi(R†R…((R!t deg_to_rads t localhosti@s Math ServersMath XML-RPC ServersΪThis server supports various mathematical functions. You can use it from Python as follows: >>> from xmlrpclib import ServerProxy >>> s = ServerProxy("http://localhost:8000") >>> s.deg_to_rad(90.0) 1.5707963267948966(R‰i@(RRR:R*R7RR€R{tSimpleXMLRPCRequestHandlerRƒRftHTMLDocRRTRlRzRR&RˆRmRXRYRZtregister_functiont register_introspection_functionst serve_forever(RlR€RTRRŠRR*R{RƒR:RRfRmRzRˆR7((R!t? s(     nQ