Am Di, den 19.10.2004 schrieb Jim Penny um 19:08:
On Tue, 19 Oct 2004 18:51:27 +0200 Tino Wildenhain <tino@wildenhain.de> wrote: ... Try it. Of course, it depends on version on python. As I recall 2.2 and earlier did not have True or False as distinguished values. But the point is a bit moot, as the SQL adapter is still responsible for converting True/False to something usable by the SQL layer.
Yeah, but we are on python2.3 already ;)
Solutions: REQUEST.get() can take a default value:
foo=REQUEST.get('foo',0)
which will return the actual value or 0
But, you hardly ever want the actual value! A checkbox creates a name in the REQUEST, along with a value. Unless you are very careful, the value will NOT be something that the SQL adapter can handle as a representation of true. Of course, you can write all your forms as
<input type="checkbox" value="1" name="foo">, but what's the point?
Usually you have checkboxes with the same name and different values to not to have to fish in the request for arbitrary variable names. So its more like: <input type="checkbox" value="1" name="foo:int:list" /> <input type="checkbox" value="2" name="foo:int:list" /> <input type="checkbox" value="3" name="foo:int:list" /> and so on. which gives you foo as list with the values (all ints in the example) foo=request.get("foo",[]) handles the case when no checkbox has ben checked. However as I said, it depends on what Laura wants to do with the data, so one or the other method is more convient. Regards Tino