How to create "cross-backend" python web app

Paul Boddie paul at boddie.org.uk
Fri Jul 15 13:42:22 CEST 2005


"matt" <matthewharrison at gmail.com> wrote in message news:<1121375775.021103.28610 at g43g2000cwa.googlegroups.com>...
> Hi all-
> 
> I'm trying to port an ajax spell-checker
> (http://www.broken-notebook.com/spell_checker/index.php) to use with
> the moin moin wiki and have been somewhat successful.  (By successful I
> mean I can spell check using the php backend and my python port running
> as cgi-bin).

That looks like an interesting application/component.

> My question is this:  moinmoin runs on many python web backends
> (cgi-bin/mod-python/twisted/standalone).  My spell-checker backend runs
> as cgi (disclaimer: I've done a bit of php and java(struts) web app
> programming, but the last python related web programming I did was Zope
> about 5 years ago (does that even count ? ;) )) because that was the
> easiest for me to get up to speed on.  What is the best way to write
> cross-backend python web apps?  Is there any abstraction I can use?

Although a kind of Web "middleware" standard called WSGI [1] has been
proposed to somehow alleviate these kinds of problems, I'd recommend
using WebStack [2] to implement a "cross-backend" solution which will
run on CGI, mod_python, Twisted, BaseHTTPServer and other
technologies.

> With cgi-bin, I use the python "cgi" module, which gives me easy access
> to form variables, but I'd like to be able to deploy in the other
> backends as well.  What's the best way to do this?  Or is a rewrite
> required for each one?

Some might argue that writing directly to WSGI would allow you to
re-use your CGI-based code moderately easily whilst having some
backend portability. I'd argue that WebStack's API is slightly more
high-level and that the WebStack distribution should provide you with
everything you need to deploy your application on the backends you've
chosen (plus others). Either way, you certainly don't need to rewrite
your application for every different environment any more.

Paul

[1] http://www.python.org/peps/pep-0333.html
[2] http://www.python.org/pypi/WebStack



More information about the Python-list mailing list