cgipm Developer's Guide
The problem is to provide a cgi tool which is familiar to Perl programmers accustomed to CGI.pm. We use the basic functionality of python's standard cgi.py, but add a wrapper for syntactic sugar.
See test01.py for an example of use in an OO setting. See test02.py for an example of use in an in-line setting.
These allow the programmer to build html tags programmatically. E.g.:
print q.tr(q.td(key),q.td(value)) builds <TR ><TD>mytxt</TD><TD>"abc"</TD></TR> <TR ><TD>myint</TD><TD>123</TD></TR> ...
Doing every single html tag would be tedious, so we support generic tagging, with tag, start_tag, and end_tag.
Both specifc and generic routines need to return strings. And they need to support variable number of arguments and variable name=value pairs.
mytxt="abc def" myint=123 myflag
For now, we build local StringIO objects, and return their values from each routine. But we could make one for the whole instantiation of CGI, and print it only at the end.
The cgipm.py module is a standalone module. It imports cgi, to get at FieldStorage, but saves that in its own _params data member. A using module would either instantiate a CGI object query=CGI() or inherit from CGI:
class myobj(CGI): CGI.__init__(self) ...