[Zope] Why is it so hard to do simple things?

Thomas B. Passin tpassin@mitretek.org
Wed, 8 May 2002 18:09:20 -0400


[Lennart Regebro]

> From: "John Adams" <jadams@inktomi.com>
> > If I was doing this in perl it'd be quite easy; I could check the query
> > variable, and act on it -- but now I have to deal with things like not
> > being able to even examine the variable without throwing an exception
>
> This has nothing to do with either Zope or Python. It has to do with how
> HTML forms are done, and yes, I agree that the people designing that
> standard are a bunch of morons.
>
> Checkboxes in form submissions has only one state. Yes, thats stupid, but
> thats how it is. Either they are checked or they don't exist at all. It is
> therefore impossible to know from the form submission whether a certain
> variable is unchecked or simply does not exist.
>
> There are basically two solutions to this.

There's another solution, one that I used on a job awhile ago.  Use the
:list syntax for the checkbox name, then test the return value (an empty
list, [], returns 0 while a non-empty list returns 1):

<input type="checkbox" name="live:list" value='checked'>

Simple and reasonable clean.  Also it's a very nice Zope feature that you
wouldn't get with ordinary CGI.

Cheers,

Tom P