More on web development

Neil Schemenauer nas at arctrix.com
Sat Jan 13 13:37:52 EST 2001


On Sat, Jan 13, 2001 at 04:23:25PM -0800, Tim Roberts wrote:
> I'm wondering now if it would be better to have the whole site dispatched
> by a single script, using the PATH_INFO part of the URL to identify a
> command to be executed.  Does anyone have any feelings about this?

It works well.  If you use something like FastCGI the script
doesn't have to start for each hit.  That's fast.  An amusing
story: the other day we were giving a demo of our new web stuff
built with Quixote.  Andrew hadn't wrote the particular piece of
code we where showing off and said something like "that's neat,
did you do that in Javascript?".  The answer was no, it was done
on the server side.  The page was being returned and rendered so
quickly that it looked like it was done client side.

Systems like Quixote and Zope use the exact scheme you describe.
A path like /q/user/login gets handled by Quixote like this:

    /q is rewritten by mod_rewrite to /cgi-bin/quixote.fcgi

    mod_fastcgi connects to the quixote.fcgi process (starting it
    if it doesn't exist, starting more if the load is high), and
    talks to it in a CGI-like way.  PATH_INFO is "/user/login".

    Quxiote takes all the CGI information and wraps it up as some
    nice objects.  It then traverses through some specified
    namespace trying to find a handler for the path.
    
    For the path above, the function is "login" in the module
    "user" in the package "ui".  Quixote calls the login
    function.  The return value is passed to Apache as the
    response.

This is only one part of what Quixote does (ie. the publishing
part).  It also does session management and templating.  PTL is a
general templating language with syntax and symantics very
similar to Python's.  In fact, we use the same bytecode
interpreter as Python.  Some simple HTML templates:

    template header(title):
        "<html><head><title>"
        title
        "</title></head><body>"
        "<h1>%s</h1>" % title

    template footer():
        "</body></html>"

    template my_page():
        header("Multiplication Fun")
        "<table>"
        for i in range(10):
            "<tr>"
            for j in range(10):
                "<td>%s x %s = %s</td>" % (i, j, i*j)
            "</tr>"
        "</table>"
        footer()

I hope I don't sound like I'm selling Quixote.  Quixote is still
changing quite dramaticly as we improve it.  We are not in the
business of building and supporting web development environments.
Zope has similar features and is much more mature.  I understand
Quixote and not Zope.  That's not saying Zope is hard.  I helped
implement Quioxte while I haven't really used Zope.  

Writing a web application environment using Python is not hard.
Using one will pay off big if your website is at all complex.

Cheers,

  Neil




More information about the Python-list mailing list