On Dec 9, 12:26 am, Michael Ströder <[EMAIL PROTECTED]> wrote: > Jeffrey Froman wrote: > > > I'd still be interested in a mod_wsgi wrapper for 3rd-party CGI scripts. > > I doubt that this is possible, not because of the interface. But > conventional CGI scripts are implemented with the assumption of being > stateless. You would have to completely reinitialize them for each hit. > Without knowledge about the internal CGI script processing this would > mean reinitializing the whole Python run-time environment. So IMHO > there's no real gain. Just my 2 c.
One doesn't necessarily need to reinitialise the whole Python run time environment. The hack that mod_python uses is to remember what Python modules had been loaded before first request. At the end of the request it will delete from sys.modules anything that was added since the beginning of the request. It also replaces os.environ in its entirety at the start of each request as well. Yes, it may not still work for all CGI scripts, eg., C extension modules may be a problem, but may be adequate for many. In fact, for some class of CGI scripts, deleting all those modules from sys.modules may not be necessary, provided you at least cause the main CGI script file to at least be reinterpreted/reimported. What degree of cleaning out the environment could be a configurable parameter of the WSGI/CGI bridge. So, although it can be done, it is the need to use strange hacks like this that means it may just be better to convert CGI script to work as WSGI, as more guarantee of success. Graham -- http://mail.python.org/mailman/listinfo/python-list