Exemplo n.º 1
0
    def beforeMain(self):
        """This is a variation of main() from _cphttptools.

        The reason it is redone here is because we don't want
        cherrypy.response.body = iterable(body) - we want to use
        whatever real value the user returned from their callable
        to reach the xmlrpcfilter unchanged."""
        
        if not cherrypy.request.xmlRpcFilterOn:
            return
        
        from cherrypy._cphttptools import mapPathToObject
        path = cherrypy.request.objectPath or cherrypy.request.path
        
        while True:
            try:
                page_handler, object_path, virtual_path = mapPathToObject(path)
                
                # Remove "root" from object_path and join it to get objectPath
                cherrypy.request.objectPath = '/' + '/'.join(object_path[1:])
                args = virtual_path + cherrypy.request.paramList
                body = page_handler(*args, **cherrypy.request.paramMap)
                cherrypy.response.body = body
                return
            except cherrypy.InternalRedirect, x:
                # Try again with the new path
                path = x.path        
Exemplo n.º 2
0
 def afterRequestHeader(self):
     domain = cpg.request.base.split('//')[1]
     if self.useXForwardedHost:
         domain = cpg.request.headerMap.get( "X-Forwarded-Host", domain)
     prefix = self.siteMap.get(domain)
     if prefix:
         # Re-use "mapPathToObject" function to find the actual
         #   objectPath
         candidate, objectPathList, virtualPathList = \
                 _cphttptools.mapPathToObject(
                     prefix + cpg.request.path
                 )
         cpg.request.objectPath = '/' + '/'.join(objectPathList[1:])
         raise basefilter.InternalRedirect