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

Changeset 959

Show
Ignore:
Timestamp:
02/07/06 11:33:59
Author:
dowski
Message:

1. Removed request.wsgi_environ from _cphttpserver.
2. Added cherrypy.server.wsgi_app attribute to ease wrapping the CP wsgiApp with WSGI middleware.
3. Modified _cpwsgiserver to set SCRIPT_NAME to and to instead put the request path in PATH_INFO. Modified _cpwsgi to deal with this change.
4. Added standalone test for mounting the CP wsgiApp at an alternate SCRIPT_NAME. Not sure how best to integrate it into the test suite.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cphttpserver.py

    r952 r959  
    8181            request.multithread = cherrypy.config.get("server.thread_pool") > 1 
    8282            request.multiprocess = False 
    83             request.wsgi_environ = {} 
    8483            response = request.run(self.raw_requestline, self._headerlist(), 
    8584                                   self.rfile) 
  • trunk/cherrypy/_cpserver.py

    r954 r959  
    88 
    99import cherrypy 
    10 from cherrypy import _cphttptools, filters 
     10from cherrypy import _cphttptools, filters, _cpwsgi 
    1111from cherrypy.lib import autoreload, profiler, cptools 
    1212 
     
    4242        self.onStartServerList = [] 
    4343        self.onStopThreadList = [] 
    44      
     44 
     45        self.wsgi_app = _cpwsgi.wsgiApp 
     46         
    4547    def start(self, init_only = False, server_class = _missing, **kwargs): 
    4648        """Main function. MUST be called from the main thread. 
     
    154156         
    155157        # Instantiate the server. 
    156         self.httpserver = self.httpserverclass() 
     158        if self.httpserverclass == _cpwsgi.WSGIServer: 
     159            self.httpserver = self.httpserverclass(self.wsgi_app) 
     160             
     161        else: 
     162            self.httpserver = self.httpserverclass() 
    157163         
    158164        # HTTP servers MUST be started in a new thread, so that the 
  • trunk/cherrypy/_cpwsgi.py

    r950 r959  
    149149                # We prepare the SizeCheckWrapper for the request body 
    150150                self.rfile.bytes_read = 0 
    151                 path = self.environ["SCRIPT_NAME"] 
     151                script_name = self.environ.get('SCRIPT_NAME', '') 
     152                path_info = self.environ.get('PATH_INFO', '') 
     153                path = (script_name + path_info) 
    152154                if path == "*": 
    153155                    path = "global" 
    154                 else: 
    155                     path = "/" + path 
    156156                mbs = int(cherrypy.config.get('server.max_request_body_size', 
    157157                                              100 * 1024 * 1024, path=path)) 
  • trunk/cherrypy/_cpwsgiserver.py

    r928 r959  
    6565            qs = "" 
    6666        self.environ["REQUEST_METHOD"] = method 
    67         if path == "*": 
    68             self.environ["SCRIPT_NAME"] = path 
    69         else: 
    70             self.environ["SCRIPT_NAME"] = path[1:] 
    71         self.environ["PATH_INFO"] = "" 
     67        self.environ["SCRIPT_NAME"] = "" 
     68        self.environ["PATH_INFO"] = path 
    7269        self.environ["QUERY_STRING"] = qs 
    7370        self.environ["SERVER_PROTOCOL"] = version 

Hosted by WebFaction

Log in as guest/cpguest to create tickets