HTML form pre-populating functionality or hints on building my own

Adam Vandenberg adamv at nwlink.com
Thu Apr 17 10:47:18 CEST 2003


> I'm wanting to find (or make) a module that will take a HTML file, locate
the
> input-related form tags (<INPUT, <TEXTAREA, <SELECT, <OPTION) and modify
them...

Here's a sample that parses some HTML and handles some form elements,
refilling them on POST-back:
http://flangy.com/dev/tinkertoys/ultraform.py
(Source: http://flangy.com/dev/tinkertoys/ultraform.py?viewsource=1 )

But unfortunately... it uses "special tags" for the forms (the t.whatever
tags.)
It would probably be easy enough to modify it to look for the regular form
tag names instead.
I specifically went with special tags because I wanted to abstract a control
from the HTML used to implement it.

I'm using the standard module sgmllib as the parser. Feel free to take the
code and run with it.
(Note that production could will want to be a lot more thorough about
cgi.escape'ing data that's taken from the form and written back out to the
page.)

Take care,
Adam Vandenberg
http://flangy.com







More information about the Python-list mailing list