Feedback wanted about the best way to write cgi scripts

Alain TESIO alain at onesite.org
Fri Sep 1 16:41:33 EDT 2000


Hello,

I've written simple functions to input html code.
You'll get the idea with the code below, this example
is for static html code,it becomes really useful for me
when there are more dynamic items.

Do you think it's terribly ugly, should I use an existing library ?

(please no flame about the first line "#! ...", it's really needed in my case !)

Thanks for your feedback
Alain



#!/usr/bin/env /home/onesite/bin/mypython

execfile('mycgi.py')

print mycgi_http_header()

print mycgi_head(base_target="left")

dateselect=mycgi_input_select("daterange",[ \
("last3months","Last 3 months"),\
("lastmonth","Last month"),\
("lastweek","Last week"),\
("dates","Date range")\
])

input_startdate=mycgi_input_text(name="startdate",size=9,style="text-align:center;",value="06/11/2000")
input_enddate=mycgi_input_text(name="enddate",size=9,style="text-align:center;",value="06/11/2000")

input_sort=mycgi_input_select("sort",[ \
("thread","Thread"),\
("date","Date"),\
("author","Author")\
])

input_submit='<input type="submit" name="idxsearch" value="Search">'

formitems=["<p>Dates :",dateselect,input_startdate,input_enddate,"</p><p>Sort by
:",input_sort,input_submit]

form_standard=mycgi_form(items=formitems,target="left",method="post",action="left.php3")

input_results_per_page=mycgi_input_select("ps",[ \
("10","10"),\
("20","20","selected"),\
("50","50")\
])

input_query_type=mycgi_input_select("m",[ \
("and","All","selected"),\
("or","Any")\
])

formitems=[mycgi_input_text("q",50),mycgi_input_submit("Search"),"<br>Results per page
:",input_results_per_page,"Query type :",inpu
t_query_type]

form_search=mycgi_form(items=formitems,method="get",action="search.php3")

print mycgi_table([[{"width":362,"text":form_standard},{"width":596,"text":form_search}]])

print mycgi_end()



More information about the Python-list mailing list