Contact: fumanchu@aminus.org

Log in as guest/misc to create tickets

Changeset 30

Show
Ignore:
Timestamp:
02/01/06 12:02:21
Author:
fumanchu
Message:

You can now set SCRIPT_NAME to whatever you like with "PythonOption? SCRIPT_NAME /path/to/approot".

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modpython_gateway.py

    r23 r30  
    55Example httpd.conf section for a CherryPy app called "mcontrol": 
    66 
    7 <Directory D:\htdocs\mcontrol> 
     7<Location /mcontrol> 
    88    SetHandler python-program 
    99    PythonHandler wsgiref.modpy_wrapper::handler 
    1010    PythonOption application cherrypy.wsgiapp::wsgiApp 
    1111    PythonOption import mcontrol.cherry::startup 
    12 </Directory> 
     12</Location> 
     13 
     14Some WSGI implementations assume that the SCRIPT_NAME environ variable will 
     15always be equal to "the root URL of the app"; Apache probably won't act as 
     16you expect in that case. You can add another PythonOption directive to tell 
     17the modpython_gateway to force that behavior: 
     18 
     19    PythonOption SCRIPT_NAME /mcontrol 
    1320 
    1421""" 
     
    93100        env = dict(apache.build_cgi_env(req)) 
    94101         
    95         if req.headers_in.has_key("authorization"): 
    96             env["HTTP_AUTHORIZATION"] = req.headers_in["authorization"] 
     102        if 'SCRIPT_NAME' in options: 
     103            env['SCRIPT_NAME'] = options['SCRIPT_NAME'] 
     104            env['PATH_INFO'] = req.uri[len(options['SCRIPT_NAME']):] 
    97105         
    98106        BaseCGIHandler.__init__(self, 
     
    105113                                ) 
    106114        self.request = req 
    107      
    108     def _write(self, data): 
    109         try: 
    110             self.request.write(data) 
    111         except IOError, x: 
    112             if "client closed connection" in x.args[0]: 
    113                 return 
    114             raise 
     115        self._write = req.write 
    115116     
    116117    def _flush(self):