The Apache mod_python and mod_snake modules embed a Python interpreter right into Apache for speed, persistence, and advanced fun(ctionality).
Next stop on our module tour is a brief gander at a couple of modules that, as mod_perl does for Perl, drop the Python language into the Apache server for speedier applications, cross-request persistence, and the ability to speak directly to the server via the Apache API.
Mod_python started its life as Httpdapy, written originally for the Netscape server, yet always intended to be cross-platform rather than server specific. From the README:
. . .I later learned that writing Httpdapy for every server is a task a little bigger and less interesting than I originally imagined. Instead, it seemed like providing a Python counterpart to the popular Perl Apache extension mod_perl that would give Python users the same (or better) capability would be a much more exciting thing to do. And so it was done.
Mod_python sports a longer history, (possibly) larger user-base, is simpler, and less "bleeding edge" than mod_snake, according to the mod_python FAQs. The mod_python site provides some wonderful, easy-to-follow installation and configuration instructions, so I leave you in their capable hands.
Mod_snake's Website also provides detailed installation, configuration, testing, and programming documentation.
While it's hard to point to the differences between the two, mod_python seems to be more geared towards beginners and those not in need of all the bells and whistles of mod_snake. If, however, you're fiddling around with the Apache 2.0 alphas or want that extra flexibility and functionality, mod_snake is probably for you.
The following is a list of starting points from which to explore further some of the topics covered (or not) in this article.
Rael Dornfest is Founder and CEO of Portland, Oregon-based Values of n. Rael leads the Values of n charge with passion, unearthly creativity, and a repertoire of puns and jokes some of which are actually good. Prior to founding Values of n, he was O'Reilly's Chief Technical Officer, program chair for the O'Reilly Emerging Technology Conference (which he continues to chair), series editor of the bestselling Hacks book series, and instigator of O'Reilly's Rough Cuts early access program. He built Meerkat, the first web-based feed aggregator, was champion and co-author of the RSS 1.0 specification, and has written and contributed to six O'Reilly books. Rael's programmatic pride and joy is the nimble, open source blogging application Blosxom, the principles of which you'll find in the Values of n philosophy and embodied in Stikkit: Little yellow notes that think.
Read more HTTP Wrangler columns.
Discuss this article in the O'Reilly Network Apache Forum.
Return to the Apache DevCenter.
Copyright © 2009 O'Reilly Media, Inc.