Handling of disabled submit buttons

10 views
Skip to first unread message

Felix Schwarz

unread,
May 13, 2009, 5:59:02 AM5/13/09
to twill-dev
Hi,

I found two issues in twill which are very annoying for me.

1. If a disabled submit button has a value, I can submit the form
anyway (using that particular submit button).
2. If a form has one submit button without a value, I can not submit the
whole form (regardless of the submit button I use).

I checked with the latest darcs revision and both issues are still
present. I attached my scripts to reproduce the issue. Hopefully it can
be fixed soon :-)

fs

server.py
test.html
twill_test.py

Nat Williams

unread,
May 14, 2009, 1:09:05 AM5/14/09
to twil...@googlegroups.com
Felix,

First, the darcs repo is somewhat defunct at this point, we've moved over to Google Code:  http://code.google.com/p/twill/  Try out the 0.9.2-dev branch and see if that solves any of your problems.  An actual 0.9.2 release has been coming Any Day Now since Pycon, but that's a different story.

Second, form handling is still one of the hairiest parts of twill, and not one that I think anyone is terribly eager to jump into at the moment.  I am seeing some wonkiness related to what you're saying, though.   It seems that ClientForm cares about a button being disabled, but twill itself does not.  This is something to investigate, but in the meantime, my suggestion is to not use buttons that are disabled.

As for your second problem, I am not able to reproduce.  Are you using tc.submit(name_of_good_button) ?


Nat

Felix Schwarz

unread,
May 14, 2009, 2:23:09 AM5/14/09
to twil...@googlegroups.com
Nat Williams schrieb:

> As for your second problem, I am not able to reproduce. Are you using
> tc.submit(name_of_good_button) ?

Yes, of course. :-)
Did you use the files I attached to reproduce the issue?

I'll check the twill version of Google code and report my findings.

fs

Felix Schwarz

unread,
May 14, 2009, 7:19:04 AM5/14/09
to twil...@googlegroups.com

Ok, I checked and I can still reproduce both problems with the latest
twill svn.

This was my original description:


"2. If a form has one submit button without a value, I can not submit
the whole form (regardless of the submit button I use)."

As I noticed just now, this should read 'If a form has one *disabled*
submit button without value' but I hope that was clear from the subject
anyway.

To reproduce, remove the value attribute from the 'calculate' submit
button in the test.html I sent earlier.

As for your suggestion not to use disabled submit buttons: Nice idea,
but I won't sacrifice usability of the website just to test it with
twill. Also sometimes you can not control the HTML of the website your
visiting....

fs

Nat Williams

unread,
May 14, 2009, 9:03:19 AM5/14/09
to twil...@googlegroups.com
On Thu, May 14, 2009 at 6:19 AM, Felix Schwarz <felix....@agile42.com> wrote:


Ok, I checked and I can still reproduce both problems with the latest
twill svn.

This was my original description:
"2. If a form has one submit button without a value, I can not submit
the whole form (regardless of the submit button I use)."

As I noticed just now, this should read 'If a form has one *disabled*
submit button without value' but I hope that was clear from the subject
anyway.

It probably would have been clear had I not been reading at midnight :)
I see what's going on, basically anything involving forms is choking on that submit button.
 

To reproduce, remove the value attribute from the 'calculate' submit
button in the test.html I sent earlier.

As for your suggestion not to use disabled submit buttons: Nice idea,
but I won't sacrifice usability of the website just to test it with
twill. Also sometimes you can not control the HTML of the website your
visiting....

I was thinking just don't click it.  But yes, twill probably should respect a button's disabledness.
 

fs



Felix Schwarz

unread,
May 14, 2009, 9:14:19 AM5/14/09
to twil...@googlegroups.com
Nat Williams wrote:
>> As for your suggestion not to use disabled submit buttons: Nice idea,
>> but I won't sacrifice usability of the website just to test it with
>> twill. Also sometimes you can not control the HTML of the website your
>> visiting....
>
> I was thinking just don't click it. But yes, twill probably should respect
> a button's disabledness.

When I wanted to test if a specific button is disabled, I thought the
easiest would be to click the button and catch the exception. :-)

fs

Terry Peppers

unread,
May 14, 2009, 1:03:34 PM5/14/09
to twil...@googlegroups.com, felix....@agile42.com
Felix -

Issue entered.

http://code.google.com/p/twill/issues/detail?id=53

Thanks for the great report and code.

- t.

Nat Williams

unread,
May 14, 2009, 2:26:27 PM5/14/09
to twil...@googlegroups.com
Felix,

I looked into your second issue a bit more.  It looks to be a bug in ClientForm rather than twill.  Even just calling tc.showforms on a page with an offending submit will throw an exception.  When ClientForm sees a submit with a value of None, it tries to set the value to an empty string.  But of course, since the submit is disabled, it chokes.

So, I don't think this is really something for us to fix.

Nat

Felix Schwarz

unread,
May 15, 2009, 5:43:03 AM5/15/09
to twil...@googlegroups.com

C. Titus Brown

unread,
May 15, 2009, 2:55:49 PM5/15/09
to twil...@googlegroups.com
On Fri, May 15, 2009 at 11:43:03AM +0200, Felix Schwarz wrote:
-> Here's a patch for that one:
-> http://sourceforge.net/mailarchive/forum.php?thread_name=3c192df10903070948n5f995d1fxe54e6d3de4784227%40mail.gmail.com&forum_name=wwwsearch-general
->
-> Let's see when it is integrated into ClientForm.

Thanks, Felix!

--titus

Reply all
Reply to author
Forward
0 new messages