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

John Adams jadams@inktomi.com
Wed, 8 May 2002 04:04:03 -0700 (PDT)


On Wed, 8 May 2002, Lennart Regebro wrote:

> 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.

Ahh, we're confused here, what I meant by my question was:

The first time it's sent, if noone's checked anything yet, then check the
first radio button by default. Now, granted, I do agree with you that CGI
processing is just stupid -- if noone checks the checkbox, you never get
the form variable back AT ALL, and that's bad design on the part of the
protocol.

> There are basically two solutions to this.
>
> 1. Define all the variables in the python method called, and let have
> defaults on the optional variables. LIke so:
>
> def     form_submission_method( self, variable1, variable2,
> thidisacheckbox=None, REQUEST):
>     #Now you can be sure there is a "thisisacheckbox" variable, and it will
> either be set, or it will be None
>     if thisisacheckbox:
>         return "It's checked!"
>
> 2. Do a check like this:
>     if hasattr(request,'perm_or_temp') and request.perm_or_temp == 'P':
>
> Btw, when doing forms, I suggest you look at formulator. It helps you
> validate forms.

Okay, I'll beat on this at work tomorrow. I've got a few good solutions to
try now.

Thanks for your help.
--john

-- 
John Adams         . Sr. Security Engineer . Inktomi Corporation