HTML generation vs PSP vs Templating Engines

Sells, Fred fred at
Thu Nov 17 00:30:24 CET 2005

If this is your first try, use cgi, cgitb and html % dictionary as suggested
in this thread.  If your db is mysql, you can actually use os.popen() (or
equivalent) to run a  'mysql -html -e "select * from yaddayadda" to return
html.  you can make that look prettier with css.
here's a quick and dirty I just did.
import os, string, sys, time, cgi, cgitb
import ezcgi
<style type="text/css" >
       table {cell-padding:2; cell-spacing:2; font-family:Arial;}
       th { background-color: lightblue; cell-padding:5; cell-spacing:5;}
       td { background-color: lightgray; padding:5; spacing:5;
<TITLE>Snapshot of Administrative Bed Holds</TITLE>
<H1><font color=darkred>Current Administrative Bed Holds at all
<H6>Copyright (C) 1996-2005, Adventist Care Centers, Inc.  For Internal Use
<A HREF="">Home</A>|
<A HREF="">Logout</A>

COMMAND = ['mysql --host=acaredb --user=acare --password=acare -D census -H
-e ', 
           '"SELECT facility,wrb Room,description Reason,startdate, note
           'FROM admin_bed_holds h, abhreasons r '
           'WHERE   ',
           ' ORDER BY facility;"']

def select_holds():
        x = os.popen(COMMAND)
        table =
        return HTML % ('', table)

def execute():
    if ezcgi.is_authenticated():
        print ezcgi.HTML_CONTENT_TYPE
        print select_holds()
if __name__=='__main__':
    #print ezcgi.PLAIN_CONTENT_TYPE
    #print COMMAND
-----Original Message-----
From: pkassianidis at [mailto:pkassianidis at]
Sent: Wednesday, November 16, 2005 11:32 AM
To: python-list at
Subject: HTML generation vs PSP vs Templating Engines

Hello everybody,

I am in the process of writing my very first web application in Python,
and I need a way to
generate dynamic HTML pages with data from a database.  I have to say I
am overwhelmed
by the plethora of different frameworks, templating engines, HTML
generation tools etc that
exist. After some thought I decided to leave the various frameworks
aside for the
time being and use mod_python.publisher along with some means of
generating HTML on
the fly.
Could someone that has used all the different ways mentioned above for
dynamic HTML
content, suggest what the pros and cons of the different methods are?

  Thank you very much in advance



The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any

More information about the Python-list mailing list