David Higgs
drh9296 at ritvax.rit.edu
Thu Feb 27 17:59:54 EST 2003
Gregory (Grisha) Trubetskoy wrote: > Your best bet is the prefork MPM. Remember that the 10M per child is > actually a lot less because pages for executables are shared between > processes on (most) UNIXes, certainly on Solaris they are. I find it hard > to believe that it is slower than regular CGI - it should be at least > several times faster, though not nearly as efficient as using the > publisher or a native handler. > > The ultimate solution is not use CGI of course :-) > > Grisha I haven't investigated things in 3.x.x yet, so I don't know if this applies. If this were for mod_python 2.x.x, I'd suggest writing a small custom handler. Just do a bit of error checking, setup a couple local variables, and an execfile(). I have an example below. Your CGIs would need to be modified to use req.write() which is somewhat annoying. For maximum compatibility, you could write a custom write() function to detect between outputting via req.write() or via stdout. On a side note, do any mod_python request objects support variable argument outputs? # httpd.conf example <Location /cgi/> SetHandler python-program PythonHandler your_handler </Location> # your_handler.py example # called by any request in this directory def handler( req ) : from mod_python import apache cur_dir = "/directory/of/this/handler/" filename = req.filename[ len( cur_dir ): ] # setup any local variables try : # all my scripts are extension-less, so # I can easily test for ".."-style hacking if filename.find( "." ) != -1 : raise IOError execfile( "/directory/of/your/scripts/" + filename ) except IOError : # handle error condition return apache.OK
|