[Zope] Form variables with same name as folder names

Curtis Maloney curtis@cardgate.net
Tue, 14 Nov 2000 10:04:12 +1100


On Tue, 14 Nov 2000, "Burwell, Becky wrote:
> Hi. I am new to using Zope and just got stuck on the following problem. I
> am trying to use forms with an SQL database.
>
> I have a form with checkboxes and I use variables like FOO to capture the
> value. For example: <input type="checkbox" name="FOO" value="1">
>
> The form has a post with the action to call a DTML document. In my DTML
> document I call a Z SQL Method called InsertMethod with REQUEST as the
> argument, for example  InsertMethod(REQUEST).
>
> My Z SQL Method InsertMethod has arguments including
> 	FOO=""
>
> And then in the body of the Z SQL method I have:
>
> <dtml-if FOO>
>    {code to insert into a database table}
>
> ----------------
> This working UNTIL I created a Folder named FOO. Then the value of FOO in
> the Z SQL method seemed to be the FOO folder and not FOO from REQUEST.  My
> workaround was to call the variable FOOCHECKBOX.
>
>
> 2) is there some way I could have referred to the variable FOO in my Z SQL
> method without resorting to renaming the variable in my form?
>

A sneaky problem indeed, and once again, one caused by "convenient" 
shortcuts. (o8

The simple answer:  use REQUEST.form['FOO']  to refer to the form variable.

The longer answer:

To make life simpler on our key-weary fingers, DC made all the form variables 
part of the namespace, but put then sufficiently down the search path so they 
wouldn't get in the way of other objects.  Most of the time this is just 
great, but occasionaly you do run into this problem.

So, you can explicitly access all form variables with REQUEST.form[]... just 
as you can access all cookies via REQUEST.cookies[] 

I would advise you make a small DTML Document containing <dtml-var REQUEST> 
just to have a look at what it contains.... THEN go and check up the ZQR for 
all the members of REQUEST... and RESPONSE, while you're at it.. (o8


> Thanks!
>
> *becky*
>

Have a better one,
	Curtis Maloney