Index: modpython_gateway.py =================================================================== --- modpython_gateway.py (revision 39) +++ modpython_gateway.py (revision 41) @@ -7,7 +7,7 @@ SetHandler python-program + PythonFixupHandler mcontrol.cherry::startup PythonHandler modpython_gateway::handler - PythonOption application cherrypy._cpwsgi::wsgiApp - PythonOption import mcontrol.cherry::startup + PythonOption wsgi.application cherrypy._cpwsgi::wsgiApp @@ -164,47 +164,7 @@ -_counter = 0 - -def profile(req): - # Call this function instead of "handler" - # to get profiling data for each call. - import hotshot, os.path - global _counter - _counter += 1 - ppath = os.path.join(os.path.dirname(__file__), "cp_%s.prof" % _counter) - prof = hotshot.Profile(ppath) - prof.runcall(handler, req) - prof.close() - return apache.OK - def handler(req): - # If you use a PythonImport directive as recommended, its interpreter_name - # value must EXACTLY match the value of req.interpreter (case-sensitive). - # You can un-comment the next line to get the value of req.interpreter. -## raise StandardError(repr(req.interpreter)) - - config = req.get_config() - debug = int(config.get("PythonDebug", 0)) - - options = req.get_options() - - # Because PythonImport cannot be specified per Directory or Location, - # take any 'import' PythonOption's and import them. If a function name - # in that module is provided (after the "::"), it will be called with - # the request as an argument. The module and function, if any, should - # be re-entrant (i.e., handle multiple threads), and, since they will - # be called per request, must be designed to run setup code only on the - # first request (a global 'first_request' flag is usually enough). - import_opt = options.get('import') - if import_opt: - atoms = import_opt.split('::', 1) - modname = atoms.pop(0) - module = __import__(modname, globals(), locals(), ['']) - if atoms: - func = getattr(module, atoms[0]) - func(req) - # Import the wsgi 'application' callable and pass it to Handler.run - modname, objname = options['application'].split('::', 1) + modname, objname = req.get_options()['wsgi.application'].split('::', 1) module = __import__(modname, globals(), locals(), ['']) app = getattr(module, objname)