Home | Trees | Indices | Help |
|
---|
|
1 import sys 2 3 import cherrypy 4 from cherrypy._cpcompat import ntob 5 6 13 1416 """Return (params, method) from request body.""" 17 try: 18 return get_xmlrpclib().loads(cherrypy.request.body.read()) 19 except Exception: 20 return ('ERROR PARAMS', ), 'ERRORMETHOD'21 2224 """Return 'path', doctored for RPC.""" 25 if not path.endswith('/'): 26 path += '/' 27 if path.startswith('/RPC2/'): 28 # strip the first /rpc2 29 path = path[5:] 30 return path31 3234 # The XML-RPC spec (http://www.xmlrpc.com/spec) says: 35 # "Unless there's a lower-level error, always return 200 OK." 36 # Since Python's xmlrpclib interprets a non-200 response 37 # as a "Protocol Error", we'll just return 200 every time. 38 response = cherrypy.response 39 response.status = '200 OK' 40 response.body = ntob(body, 'utf-8') 41 response.headers['Content-Type'] = 'text/xml' 42 response.headers['Content-Length'] = len(body)43 4446 xmlrpclib = get_xmlrpclib() 47 if not isinstance(body, xmlrpclib.Fault): 48 body = (body,) 49 _set_response(xmlrpclib.dumps(body, methodresponse=1, 50 encoding=encoding, 51 allow_none=allow_none))52 5355 body = str(sys.exc_info()[1]) 56 xmlrpclib = get_xmlrpclib() 57 _set_response(xmlrpclib.dumps(xmlrpclib.Fault(1, body)))58
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Jun 30 21:23:20 2014 | http://epydoc.sourceforge.net |