Home | Trees | Indices | Help |
|
---|
|
1 import sys 2 3 import cherrypy 4 from cherrypy._cpcompat import ntob 5 1214 """Return (params, method) from request body.""" 15 try: 16 return get_xmlrpclib().loads(cherrypy.request.body.read()) 17 except Exception: 18 return ('ERROR PARAMS', ), 'ERRORMETHOD'19 2022 """Return 'path', doctored for RPC.""" 23 if not path.endswith('/'): 24 path += '/' 25 if path.startswith('/RPC2/'): 26 # strip the first /rpc2 27 path = path[5:] 28 return path29 3032 # The XML-RPC spec (http://www.xmlrpc.com/spec) says: 33 # "Unless there's a lower-level error, always return 200 OK." 34 # Since Python's xmlrpclib interprets a non-200 response 35 # as a "Protocol Error", we'll just return 200 every time. 36 response = cherrypy.response 37 response.status = '200 OK' 38 response.body = ntob(body, 'utf-8') 39 response.headers['Content-Type'] = 'text/xml' 40 response.headers['Content-Length'] = len(body)41 4244 xmlrpclib = get_xmlrpclib() 45 if not isinstance(body, xmlrpclib.Fault): 46 body = (body,) 47 _set_response(xmlrpclib.dumps(body, methodresponse=1, 48 encoding=encoding, 49 allow_none=allow_none))5052 body = str(sys.exc_info()[1]) 53 xmlrpclib = get_xmlrpclib() 54 _set_response(xmlrpclib.dumps(xmlrpclib.Fault(1, body)))55
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Feb 9 16:10:53 2012 | http://epydoc.sourceforge.net |