Form Parsing resouces

Tim Johnson tim at johnsons-web.com
Tue Oct 27 22:16:07 CET 2009


Using python 2.5 on linux.
I am an experienced web programmer. 8 years with python.
I have done the following in other programming languages, but not so far
in python:

1)Parse a form into alternating strings and tags.
2)Convert tags into dictionary-like objects.
 Said process would allow me to then modify the objects and in the same
 sequence print out the string along with the objects to stdout.

 The goal is to 
1)Read a form - with no special markups, pseudo attributes
 or "template code" - from a file. Parse as above.
2)Read a record from a database. 
3)Insert the column values into corresponding dictionary objects and then
 reproduce the form as "filled" in.

If such a module existed, it would be wonderful, but if not, pointing me
to a starting point would be most welcome. The starting point would be a
python module that read a string containing html tags and seperates the
tages from the string.

Example="""
This is my form
<form method="POST" action="some.cgi" name="form0">
Enter Name  <input type="text" size="40" name="firstname">
</form>
""" 
## result 
["This is my form",
{"tagtype":"form","action":"some.cgi","name":"form0"},
"Enter Name ",
{"tagtype":"input","type":"text","size":"40","name":"firstname"}
{"tagtype":"/form"}]

FYI: I have looked at ClientForm. It appears that ClientForm enables the
reading of a form as a request, modifying it and sending it directly
back to a process. I need something to provide a form directly to
stdout to enable a user to edit it.

TIA
-- 
Tim 
tim at johnsons-web.com
http://www.akwebsoft.com



More information about the Python-list mailing list