Faster Web Applications with SCGI
Once you're comfortable writing programs using SCGI, you may want to try adapting existing applications to use it. Some well-known Web applications, such as MoinMoin (a wiki) and Trac (a wiki-based collaborative development environment), are implemented as Python modules. Both of these examples come with CGI scripts in Python that can be called from Apache. The CGI scripts are very short; they really don't do anything except import the application's modules and invoke a function on them.
If you find an application like that, all you really need to do to make it work with SCGI is take that little bit of Python code and move it into a produce() method, as in the examples you've seen here. If you have SCGI 1.12 or newer, you also might want to take a look at an alternative SCGIHandler method, produce_cgilike().
That's about all we have room for. If you wonder about how the CGI parameters work, try looking at the CGI standard, which calls them “request meta-variables” (see Resources).
Finally, a word of warning. You'll notice that the last example program dies horribly if you fail to pass the expected arguments. The SCGI server replaces the failing processes, so in this case, there's no real problem. But, this should remind you how careful you need to be when writing Web applications. Never trust the input you receive from outside! If a program can be crashed, someone can probably subvert it or take it out of action. People all over the world do that sort of thing for fun or profit, so take the risk seriously.
SCGI Downloads: quixote.python.ca/releases
SCGI Home Page: www.mems-exchange.org/software/scgi
CGI Standard: ftp.rfc-editor.org/in-notes/rfc3875.txt
More on SCGI with Python and Apache2: thaiopensource.org/development/suriyan/wiki/UsingScgi
Perl Interface: search.cpan.org/~vipercode/SCGI/lib/SCGI.pm
Lisp Interface: randallsquared.com/download/scgi
Jeroen Vermeulen works for the Open Source Department of the Thai Software Industry Promotion Agency. He's currently working on Suriyan, a server system for those who don't have time for server systems.
- Nice coding on the cake. I
3 hours 19 min ago
- Baker's identity
8 hours 8 min ago
- Uber jealous
13 hours 5 min ago
- Reality is disapointing
23 hours 38 min ago
- Máy sấy quần áo
1 day 2 hours ago
- Services on GlusterFS
1 day 2 hours ago
- Reply to comment | Linux Journal
1 day 4 hours ago
- Definitely cool stuff here
1 day 5 hours ago
- thanks for the information
1 day 6 hours ago
- nice information thanks
1 day 7 hours ago