Sorry about the delay, I've been awful busy.

Anyway, that wasn't as bad as I thought. CherryPy cleared up their
handling of requests and threads, and that's where my error was coming
from. Robert Brewer was kind enough to provide a fix, and I'm relaying
it here.

For easy reference, directions from my previous post are cut and paste
here. the changes to mpcp.py are at the bottom, so skip ahead if you
know the story. Please let me know how it goes, so that I can again
dive into the depths unknown. :)

-- snip --
Go grab the mpcp.py from http://www.jamwt.com/ and put it into $TG_MP.
Ideally, you could just grab it from easy_install, but I had a problem
getting the mpcp to be seen in mod_python's $PYTHONPATH so that was my
workaround.

Put an .htaccess file in $TG_MP with the following:
--
SetHandler mod_python
PythonHandler mpcp
PythonDebug On
PythonOption cherrysetup [ $NAME_OF_YOUR_START_SCRIPT]::mp_setup
--
Warning! The start script is usually MyAppName-start.py, and the dash
will screw up the PythonOption. Ergo, lose the dash and there shouldn't
be any problems.

Now, in your (newly renamed) MyAppName_start.py make the following
changes:

1) move cherrypy.server.start() so it only starts if __name__ ==
"__main__". This might be unnecessary, but I really enjoy typing, so
whatever.

if __name__ == "__main__":
   cherrypy.server.start()

2) create a new no-op method, called mp_setup().  As such:
def mp_setup():
   pass

This method is supposed to have cherrypy production config stuff, but
our prod.cfg file handles that, so make it a no-op. The better solution
would be to remove the line in mpcp that looks for cherrysetup, but
that's something I'll worry about when a push to production is near.
-- / snip --

*** NEW ***
Now, in mpcp.py add the following lines, as per Robert's patch.

...
def handler(req):
        config = req.get_config()
        options = req.get_options()
        setup(options)

+       # Create new threadlocal objects for the current
request/response
+       cherrypy.request.purge__()
+       cherrypy.response.purge__()

        # Vars needed by cherrypy
        clientAddress = req.connection.remote_ip
...

Restart apache, and let me know how it goes. If I get a good success
rate, I'll post these directions to trac.

leo

Reply via email to