...
>
> Which seems to make it work correctly.
Thanks for the bug report and fix. I incorporated your change and it
worked. I've substituted regsub.gsub('+', ' ', str) for your function
enspace(str).
>
> I also added the useful utility routine:
>
> def wrap( co, s ):
> return "<" + co + ">\n" + s + "\n</" + co + ">\n"
>
>
> called as in:
> print wrap( 'HD2', "The Query: " )
I added this to a tohtml.py, file. It was probably a mistake to
include print_header(str) and print_title(str) in cgi.py. They are
functions for generating HTML code, not for manipulating cgi
information. I've moved copies of them to tohtml. I'll probably
delete them from cgi.py after I've cleaned up the scripts that call
them.
>
> A printlist() that formats python lists as HTML LISTS and
> python dictionaries as HTML DEFINITION LISTS would also be
> useful
I've added a print_sorted_dict() and print_list() function to tohtml.py.
There seems to be a need for a general mapping, but I can't envision
what that might be.
> >>> a='<sdm7g@Virginia.EDU>'
> >>> print regsub.gsub( '>', '>', regsub.gsub( '<','<',a))
> <sdm7g@Virginia.EDU>
>
>
> Works find if you already have a string, but can anyone thing
> of a way to globally change ALL the repr's so that all expressions
> printed would be globally changed ? The you could print lists,
> dictionaries, ( <Class instances> ), etc. in a python CGI script
> without worry!
> ( Come to think of it, this might be a good job for one of my
> "fake file" classes or 'tofile()' functions! i.e. put everything
> that produces any output into a main() function, and call
> tofile() with 'main' and a file-like Class that filters out
> the unallowed characters! -- convert newlines to '<BR>', etc. )
Is your tofile() function documented in an archive somewhere? I
recall seeing it posted awhile back.
> Anybody else have any good Python WWW utilities ?
> ( besides, of course, the stuff in the library already: urllib &
> httplib, plus Michael's cgi.py )
Look in http://www.eeel.nist.gov/python/ for an update of the cgi.py
file and the tohtml.py file.
Michael J. McLay
National Institute of Standards and Technology
Bld 220 Rm A357 (office), Bld 220 Rm B344 (mail)
Gaithersburg, Maryland 20899, (301)975-4099