[twill] Intuitively Filling Out Forms
Terry Peppers
peppers at gmail.com
Fri Sep 28 14:03:16 PDT 2007
Before Titus disappears for awhile (congrats, by the way!), I had a
question on how to better fill out forms.
Let's say we have a form like this:
<form action="foo.html" method="POST">
<input type="text" name="first_name">
<input type="text" name="last_name">
<input type="submit" name="submit" value="submit">
</form>
Is there a way I can get @ the inputs without knowing the form name?
What if I want to write a function like:
def fill_out_middle_initial():
fv(1, "middle_name", "Allen")
Twill's going to throw an exception since that field doesn't exist. I
could catch and just let go of it like:
def fill_out_middle_initial():
try:
fv(1, "middle_name", "Allen")
except:
pass # No middle name field, Bub
But that doesn't seem right to me. In fact, I think a conditional
would be better. Something like:
def fill_out_middle_initial():
# if the field name "middle_name" exists:
# input a value
Ideas? Suggestions? Hints?
I was poking around with "get_all_forms()" and "get_forms()" but am
stuck @ how to look @ the forms actual attributes.
More information about the twill
mailing list