コード例 #1
0
ファイル: xmlrpcfilter.py プロジェクト: bieschke/nuffle
    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        
コード例 #2
0
ファイル: virtualhostfilter.py プロジェクト: 3ft9/btdaemon
 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