Changeset 729
- Timestamp:
- 10/08/05 16:33:46
- Files:
-
- trunk/cherrypy/lib/filter/xmlrpcfilter.py (modified) (2 diffs)
- trunk/cherrypy/test/test_xmlrpc_filter.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/lib/filter/xmlrpcfilter.py
r665 r729 180 180 # used for debugging and more info 181 181 # print "XMLRPC Filter: calling '%s' with args: '%s' " % (cherrypy.request.path,params) 182 183 def beforeMain(self): 184 """This is a variation of main() from _cphttptools. 185 186 The reason it is redone here is because we don't want 187 cherrypy.response.body = iterable(body) - we want to use 188 whatever real value the user returned from their callable 189 to reach the xmlrpcfilter unchanged.""" 190 191 if not cherrypy.request.xmlRpcFilterOn: 192 return 193 194 from cherrypy._cphttptools import mapPathToObject 195 path = cherrypy.request.objectPath or cherrypy.request.path 196 197 while True: 198 try: 199 page_handler, object_path, virtual_path = mapPathToObject(path) 200 201 # Remove "root" from object_path and join it to get objectPath 202 cherrypy.request.objectPath = '/' + '/'.join(object_path[1:]) 203 args = virtual_path + cherrypy.request.paramList 204 body = page_handler(*args, **cherrypy.request.paramMap) 205 cherrypy.response.body = body 206 return 207 except cherrypy.InternalRedirect, x: 208 # Try again with the new path 209 path = x.path 182 210 183 211 def beforeFinalize(self): … … 188 216 189 217 encoding = cherrypy.config.get('xmlRpcFilter.encoding', 'utf-8') 190 191 if not isinstance(cherrypy.response.body, list):192 cherrypy.response.body = [cherrypy.response.body]193 218 194 219 cherrypy.response.body = [xmlrpclib.dumps( 195 (cherrypy.response.body [0],),220 (cherrypy.response.body,), 196 221 methodresponse=1, 197 222 encoding=encoding, 198 223 allow_none=1)] 199 224 cherrypy.response.headerMap['Content-Type'] = 'text/xml' 200 cherrypy.response.headerMap['Content-Length'] = `len(cherrypy.response.body [0])`225 cherrypy.response.headerMap['Content-Length'] = `len(cherrypy.response.body)` 201 226 202 227 def beforeErrorResponse(self):

