Forms sometimes come with multiple submit buttons. Sometimes they're the same, sometimes they're different. Often, a group of submit buttons will be repeated in different places on a form. Which 'blah' button you press generally doesn't matter, and can be checked by testing the name and value fields. I've attached a patch to modify the '_all_the_same_checkbox' function in browser.py to also check submit buttons. In order to facilitate this, and also to make things a bit safer for the 'checkbox' and 'hidden' fields already handled, it has been renamed to '_all_the_same_control' and the 'value' field of the control is checked as well as the 'name' field.

Patch was generated from 'darcs send -o patch.txt'.

Tom Parker
New patches:

[Add submit buttons to multiple identical control checks
[EMAIL PROTECTED] {
hunk ./twill/browser.py 331
-    def _all_the_same_checkbox(self, matches):
+    def _all_the_same_control(self, matches):
hunk ./twill/browser.py 333
+               value = None
hunk ./twill/browser.py 335
-            if match.type not in ['checkbox', 'hidden']:
+            if match.type not in ['checkbox', 'hidden', 'submit']:
hunk ./twill/browser.py 339
+                               value = match.value
hunk ./twill/browser.py 341
-                if match.name != name:
+                if match.name != name or match.value!= value:
hunk ./twill/browser.py 358
-                or self._all_the_same_checkbox(matches)):
+                or self._all_the_same_control(matches)):
hunk ./twill/browser.py 384
-                    or self._all_the_same_checkbox(matches)):
+                    or self._all_the_same_control(matches)):
}

Context:

[bumped version number to 0.8.1a5
[EMAIL PROTECTED] 
[extensions now twill.extensions; added sureshvv's stuff in as match_parse 
extension
[EMAIL PROTECTED] 
[incr to a4
[EMAIL PROTECTED] 
[fixed problems with 'title'
[EMAIL PROTECTED] 
[formfile now uses 'rb' to open files
[EMAIL PROTECTED] 
[updated to a2
[EMAIL PROTECTED] 
[updated form tests a bit; ChangeLog
[EMAIL PROTECTED] 
[Allow multiple checkbox form fields with same name.
[EMAIL PROTECTED]
 
 Nevow formless adds hidden fields with False values
 to ensure it gets something back, even if the button
 was not checked.
] 
[Avoid untrue error message when no clickies are found.
[EMAIL PROTECTED]
 
 Used to set found_multiple even when clickies==[],
 which lead to error message "multiple matches to ..",
 when the right error message was "no field matches ..".
] 
[updated to a1
[EMAIL PROTECTED] 
[fixed form sub/referer issue
[EMAIL PROTECTED] 
[more cleanup
[EMAIL PROTECTED] 
[removed HTMLParser.py
[EMAIL PROTECTED] 
[whoops; added wsgi_intercept
[EMAIL PROTECTED] 
[fixed tests when run as scripts; renamed myhttplib to wsgi_intercept, used 
latest wsgi_intercept code
[EMAIL PROTECTED] 
[minor changes to README
[EMAIL PROTECTED] 
[minor cleanup fostered by pychecker
[EMAIL PROTECTED] 
[fixed tests so that they work with latest version of nose
[EMAIL PROTECTED] 
[updated version to 0.8.1, prophylactically
[EMAIL PROTECTED] 
[added ctb-notes
[EMAIL PROTECTED] 
[TAG release-0.8
[EMAIL PROTECTED] 
Patch bundle hash:
1f5c7361691b03bc110ae5d6a3532b8576bd0884
_______________________________________________
twill mailing list
[email protected]
http://lists.idyll.org/listinfo/twill

Reply via email to