Python web frameworks

M

Michael Ströder

Jeffrey said:
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.

Ciao, Michael.
 
I

Istvan Albert

But conventional CGI scripts are implemented with the assumption of being
stateless.

while it might be that some CGI scripts must be executed in a new
python process on each request, common sense and good programming
practices would steer most people away from that sort of approach.

after all such CGI scripts would not execute properly under mod_python
either

i.
 
G

Graham Dumpleton

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top