Ñò °›—Ic@sdZddkZddkZddkZddkZddklZddklZddk l Z l Z dgZ ei eƒZedfedfed fed fed fed feid feidffZd„Zd„Zdefd„ƒYZdefd„ƒYZdS(sThe base WSGI XMLRPCControlleriÿÿÿÿN(treplace_header(tWSGIController(taborttResponsetXMLRPCControllertstringtarraytbooleantinttdoubletstructsdateTime.iso8601tbase64cCsTg}xG|D]?}x6tD].\}}t||ƒo|i|ƒPqqWq W|S(sfReturns a list of the function signature in string format based on a tuple provided by xmlrpclib.(tXMLRPC_MAPPINGt isinstancetappend(targst signaturetparamttypetxml_name((s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pyt xmlrpc_sigs   cCs.ti||ƒ}tdti|dtƒƒS(s;Convienence method to return a Pylons response XMLRPC Faulttbodytmethodresponse(t xmlrpclibtFaultRtdumpstTrue(tcodetmessagetfault((s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pyt xmlrpc_fault!scBs§eZdZeZdZd„Zd„Zd„Zd„Z d„Z d„Z d„Z d gge _ d „Zd d gd d gge_ d „Zd d gge_ RS( sÛXML-RPC Controller that speaks WSGI This controller handles XML-RPC responses and complies with the `XML-RPC Specification `_ as well as the `XML-RPC Introspection `_ specification. By default, methods with names containing a dot are translated to use an underscore. For example, the `system.methodHelp` is handled by the method :meth:`system_methodHelp`. Methods in the XML-RPC controller will be called with the method given in the XMLRPC body. Methods may be annotated with a signature attribute to declare the valid arguments and return types. For example:: class MyXML(XMLRPCController): def userstatus(self): return 'basic string' userstatus.signature = [ ['string'] ] def userinfo(self, username, age=None): user = LookUpUser(username) response = {'username':user.name} if age and age > 10: response['age'] = age return response userinfo.signature = [['struct', 'string'], ['struct', 'string', 'int']] Since XML-RPC methods can take different sets of data, each set of valid arguments is its own list. The first value in the list is the type of the return argument. The rest of the arguments are the types of the data that must be passed in. In the last method in the example above, since the method can optionally take an integer value both sets of valid parameter lists should be provided. Valid types that can be checked in the signature and their corresponding Python types:: 'string' - str 'array' - list 'boolean' - bool 'int' - int 'double' - float 'struct' - dict 'dateTime.iso8601' - xmlrpclib.DateTime 'base64' - xmlrpclib.Binary The class variable ``allow_none`` is passed to xmlrpclib.dumps; enabling it allows translating ``None`` to XML (an extension to the XML-RPC specification) .. note:: Requiring a signature is optional. i@cCs|iS(N(t rpc_kargs(tself((s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pyt_get_method_argsisc s|i}|idƒ}|ot|ƒ}n#|otidƒntdƒ||ijp |djo2|otid|i|ƒntddƒn|dit|dƒƒ}ti |ƒ\}}|i |ƒ}|i |ƒ} | p6|otid |ƒnt dd |ƒ||ƒSt | d ƒoÎ|otid ƒnt} t|ƒ} xQ| iD]F} t| ƒd t|ƒjoqqn| | d jo t} PqqqqW| pE|otidƒnd| | i|f} t d| ƒ||ƒSnti| ƒdd }tt||ƒƒ}|||d<|d<||d<||_| |_g‰g‰g‰d‡‡‡fd†}ti|||ƒ}t|ƒ}ˆidtt|dƒƒfƒtˆddƒ|ˆdˆˆdƒ|S(sWParse an XMLRPC body for the method, and call it with the appropriate argumentstCONTENT_LENGTHs,No Content-Length found, returning 411 errori›isRContent-Length larger than max body length. Max: %s, Sent: %s. Returning 413 errorisXML body too larges wsgi.inputs,Method: %r not found, returning xmlrpc faultsNo such method name %rRs"Checking XMLRPC argument signatureis7Bad argument signature recieved, returning xmlrpc faultsSIncorrect argument signature. %r recieved does not match %r signature for method %rtactiontenvirontstart_responsecs+ˆi|ƒˆi|ƒˆi|ƒdS(N(Rtextend(t new_statust new_headerst new_exc_info(tstatustheaderstexc_info(s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pytchange_content´s  sContent-Lengths Content-Typestext/xmlN( t_pylons_log_debugtgetRtlogtdebugRtmax_body_lengthtreadRtloadst_find_method_namet _find_methodRthasattrtFalseRRtlenRtinspectt getargspectdicttzipRt_functNoneRt__call__tlistRtstrR(R R$R%t log_debugtlengthRtrpc_argst orig_methodtmethodtfunct valid_argstparamstsigtmsgtarglisttkargsR-toutput((R*R+R,s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pyR@lsp             #cCsT|i|iƒ}t|tiƒp |f}nti|dtd|iƒ}|S(s4Dispatch the call to the function chosen by __call__Rt allow_none(t _inspect_callR>R RRRRRP(R t raw_responsetresponse((s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pyt_dispatch_call¿s   cCs—|idƒo |iotidƒndS|iotid|ƒnyt||dƒ}Wntj odSXt|ti ƒo|SdS(sMLocate a method in the controller by the specified name and return itt_s0Action starts with _, private action not allowedNsLooking for XMLRPC method: %r( t startswithR.R0R1tgetattrR?tUnicodeEncodeErrorR ttypest MethodType(R tnameRH((s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pyR6És  cCs|iddƒS(sÁLocate a method in the controller by the appropriate name By default, this translates method names like 'system.methodHelp' into 'system_methodHelp'. t.RU(treplace(R R[((s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pyR5ÛscCs|iddƒS(s¼Translate an internal method name to a publicly viewable one By default, this translates internal method names like 'blog_view' into 'blog.view'. RUR\(R](R R[((s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pyt_publish_method_nameäscCsng}xat|ƒD]S}t||ƒ}|idƒ o-t|tiƒo|i|i|ƒƒqqW|S(s;Returns a list of XML-RPC methods for this XML-RPC resourceRU(tdirRWRVR RYRZRR^(R tmethodsRGtmeth((s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pytsystem_listMethodsís  RcCsD|i|i|ƒƒ}|ot|ddƒStiddƒSdS(s Returns an array of array's for the valid signatures for a method. The first value of each array is the return value of the method. The result is an array to indicate multiple signatures a method may be capable of. RtisNo such method nameN(R6R5RWRR(R R[RG((s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pytsystem_methodSignatureùs RcCsn|i|i|ƒƒ}|o?ti|ƒ}t|ddƒ}|o|d|7}n|StiddƒS(s&Returns the documentation for a methodRs Method signature: %sisNo such method nameN(R6R5t MethodHelptgetdocRWR?RR(R R[RGthelpRK((s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pytsystem_methodHelp s(t__name__t __module__t__doc__R8RPR2R!R@RTR6R5R^RbRRdRh(((s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pyR's >  S     RecBs,eZdZd„Zd„ZeeƒZRS(sDWrapper for formatting doc strings from XMLRPCController methodscCs ||_dS(N(Rk(R tdoc((s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pyt__init__scCsWt|ddƒ}|djo |i}ntit|ƒƒ}|djodS|S(sÜReturn a formatted doc string, via inspect.getdoc, from the specified XMLRPCController method The method's help attribute is used if it exists, otherwise the method's doc string is used. RgRcN(RWR?RkR:RfRe(RGRgRl((s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pyRfs   (RiRjRkRmRft staticmethod(((s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pyRes  (RkR:tloggingRYRtpaste.responseRtpylons.controllersRtpylons.controllers.utilRRt__all__t getLoggerRiR0t basestringRAtboolRtfloatR<tDateTimetBinaryR RRRtobjectRe(((s=/usr/lib/python2.6/site-packages/pylons/controllers/xmlrpc.pyts"       ð