cgimodel: CGI Programming Made Easy with Python

Always look on the bright side of life and at a method for debugging CGI programs on the command line.
Adding Existing Modules to CGI

Assume you already have this module:

#!/usr/bin/env python
def  Method1(name1,name2,name3):
        print name1,name2,name3
if __name__ == '__main__':

Edit the module, inserting the following method under the class Dispatcher:

def cmd_TestMeth(self,parDict):
   import testmethod
   name1 = parDict['name1']
   name2 = parDict['name2']
   name3 = parDict['name3']
Now it is ready! You can call this on the command line by typing on one line: -fun TestMeth -name1 one -name2 two -name3 three
or by URL (all on one line):
or by FORMS:
<FORM METHOD="post" ACTION="/cgi-bin/">
<INPUT TYPE=hidden name=fun value=TestMeth>
<INPUT TYPE=hidden name=name1 value=one>
<INPUT TYPE=hidden name=name2 value=two>
<INPUT TYPE=hidden name=name3 value=three>
It would be much better if you could separate HTML text from CGI modules, so that CGI looks thinner and more readable. You can use the template modules (see Resources) to do this. The template module keeps the text away from the CGI and has a page-paragraph structure. Each CGI call can be associated with a page, and each paragraph can be used to set up the view of your HTML page.

cgimodel can host any number of applications. The redundancy of writing a CGI front end is no longer necessary. Since many applications can be run by a single cgimodel, logging information particular to each application can be done for later analysis to improve server performance, stability of each application, better service, etc. Currently, this can be done with the log information generated by the web server.

With, and possibly the modules, you should find writing and testing CGI programs easier.


Chenna Ramu ( holds a postgraduate degree in mathematics. He currently works for European Molecular Biological Laboratory in Heidelberg, Germany, in the area of biocomputing. Interests are theoretical study about DNA/protein sequences, database development, parsing, compilers, system administration and web technology. He came across Python recently (thanks to Gert Vriend) and found it quite nice for programming.

Christine Gemuend has a degree in computer science. She is interested in parallel computers and database systems, and is working in the area of informatics.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


Anonymous's picture
Phospho.ELM: a database of phosphorylation sites—update 2008
Francesca Diella, Cathryn M. Gould, Claudia Chica, Allegra Via, and  Toby J. Gibson
Nucleic Acids Res. . 2008 January; 36(Database issue): D240–D244. Published online 2008 January. doi: 10.1093/nar/gkm772.
PMCID: PMC2238828

 Phospho.ELM: A database of experimentally verified phosphorylation sites in eukaryotic proteins
Francesca Diella, Scott Cameron, Christine Gemünd, Rune Linding, Allegra Via, Bernhard Kuster, Thomas Sicheritz-Pontén, Nikolaj Blom, and  Toby J Gibson
BMC Bioinformatics. . 2004; 5: 79. Published online 2004 June 22. doi: 10.1186/1471-2105-5-79.
PMCID: PMC449700

 SIRW: a web server for the Simple Indexing and Retrieval System that combines sequence motif searches with keyword searches
Chenna Ramu
Nucleic Acids Res. . 2003 July 1; 31(13): 3771–3774. 
PMCID: PMC168953

 ELM server: a new resource for investigating short functional sites in modular eukaryotic proteins
Pål Puntervoll, Rune Linding,,
Nucleic Acids Res. . 2003 July 1; 31(13): 3625–3630. 
PMCID: PMC168952

Gene2EST: a BLAST2 server for searching expressed sequence tag (EST) databases with eukaryotic gene-sized queries
Christine Gemünd, Chenna Ramu, Brigitte Altenberg-Greulich, and  Toby
 J. Gibson
Nucleic Acids Res. . 2001 March 15; 29(6): 1272–1277. 

The points is it solves the

Anonymous's picture

The points is it solves the problem of debugging cgi's,
since you can do it on the command line. But isn't
that unix/linux specific ? Will it work for windows?


Re: cgimodel: CGI Programming Made Easy with Python

Anonymous's picture

The author has done a very good job of designing a fantastic framework for cgi's. I am now writing cgi's with python!