Web devel with python. Whats the best route?

Alex Martelli aleaxit at yahoo.com
Mon Jan 8 17:25:23 EST 2001


"Moshe Zadka" <moshez at zadka.site.co.il> writes:

> > CGI.  Really.  Your admin system doesn't look like the kind of thing
that
> > will be continuously getting multiple hits a second, making CGI overhead
> > a problem.  If that is the case, CGI is easiest.  *Do the simplest thing
> > that can possibly work*!
>
> CGI is not an answer. Perhaps you meant "CGI with lots of little
> print '<HTML>' this and print '<BODY>' that", which is as far from
> the simplest thing that could possible work as possible. Most Python web

Actually, I think the simplest way to generate HTML output in most
cases is by smart copying of an input template (which is HTML with
embedded Python expressions and a few Python statements -- if,
for, while).  The 'smart-copy' facility was the first significant Python
utility I ever wrote for myself, back as a very, very raw Python newbie:
a few well-invested hours mostly spent learning the details of how re's
work in Python.  I think I could redo it now in a couple of hours if I
had to, of course, having learned some Python in the meantime (my
first, and still-working, version, was far too rich in functionality,
allowing
completely-general RE's to demarcate embedded expression, statements,
etc, for example; "I'm younger than that now").

The cool thing (from my POV) is I can use any decent HTML editor
(I recommend Arachnophylia, but of course there's a surfeit of them
around, of all shades between wysiwybywg [what you see is what you
_believe_ you will get] and vim's textediting+syntax colouring) as a 'GUI
builder', with just a little touch of text-editing to ensure the needed
embedded-expressions and conditional and repeated portions.

In any case, if you prefer other approaches such as HTMLgen or
whatever, by all means go for them -- they're not really very related
to the question at hand.  Who's saying you're going to output HTML
at all, rather than XHTML, XML, plaintext, or whatever?  That may
depend on the details of the query you get, current state, blah blah.

Before that becomes an issue, your Python code has to be running
in response to a 'query'; the question was posed in the context of how
to get that to happen (mod_this, mod_that, PyTheOther) -- and my
point is that the simplest practicable way is likely to be CGI, using (if
one needs session continuity) cookies and perhaps shelves.


> Of course, the simplest thing that can possible work
interface-to-the-browser
> part is of course not even going with CGI, but with inheriting from
> BaseHTTPRequestHandler.

I fail to see how that's simpler than 'import cgi', which parses up GET or
POST parameters in a simple, standard way and presents them to your
code in a very dict-like way (OK, the cgi module itself could be simpler,
no doubt -- but, there's a PEP out on Python Web enhancements, isn't
there?).  Then you can run CGIHTTPRequestHandler directly, or Xitami,
or Apache, or PWS, or whatever other webserver you think is the easiest
and simplest to run, administer, and keep running.


Alex



__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com




More information about the Python-list mailing list