Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 729

Show
Ignore:
Timestamp:
10/08/05 16:33:46
Author:
dowski
Message:

1. Fix for #339
2. Test for xmlrpcfilter (not integrated into test.py yet)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/lib/filter/xmlrpcfilter.py

    r665 r729  
    180180        # used for debugging and more info 
    181181        # 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         
    182210     
    183211    def beforeFinalize(self): 
     
    188216 
    189217        encoding = cherrypy.config.get('xmlRpcFilter.encoding', 'utf-8') 
    190  
    191         if not isinstance(cherrypy.response.body, list): 
    192             cherrypy.response.body = [cherrypy.response.body] 
    193218         
    194219        cherrypy.response.body = [xmlrpclib.dumps( 
    195             (cherrypy.response.body[0],), 
     220            (cherrypy.response.body,), 
    196221            methodresponse=1, 
    197222            encoding=encoding, 
    198223            allow_none=1)] 
    199224        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)` 
    201226     
    202227    def beforeErrorResponse(self): 

Hosted by WebFaction

Log in as guest/cpguest to create tickets