[Zope] REQUEST weirdness . . .
Christopher J. Kucera
ckucera@globalcrossing.com
Fri, 31 Mar 2000 17:29:26 -0600
'ello.
Bear with me on this one; I'm having worlds of problems coming up
with any kind of coherent way of expressing the problem. :)
I have a form which contains the following:
<input type=text name="street.address1:record">
<input type=text name="street.address2:record">
<input type=text name="street.city:record">
<input type=text name="street.state:record">
<input type=text name="street.zip:record">
To parse this data, I would ordinarily just use a dtml-with:
<dtml-with street>
<dtml-var address1>, etc, etc, etc
</dtml-with>
No problem. This, however, is where things get interesting.
I'm passing the data from this form to a "confirmation"
page. The data from the first form will be simply put into a bunch
of "hidden" fields, where the user will be prompted to REALLY do what
they were doing, or cancel back to the original form.
Now, I don't want to have to re-code the confirmation page every
time I add a new value to the main form, or remove an input for
whatever reason. What I figured I would do is the following:
<dtml-in "REQUEST.form.keys()">
<input type=hidden
name="<dtml-var sequence-item>"
value="<dtml-var "REQUEST.form[_['sequence-item']]">">
</dtml-in>
This works fine for all the values in the form which aren't using
the ":record" tag, but obviously for my address, I'll
need to iterate through it. ie:
<dtml-in "REQUEST.form['street'].keys()">
<input type=hidden
name="street.<dtml-var sequence-item>:record"
value="<dtml-var "REQUEST.form['street'][_['sequence-item']]">">
</dtml-in>
( In the original code, "street" wasn't hardcoded, and I just wrapped
that statement around a dtml-try, where the except clause was my
original dtml-in. )
This code doesn't work. Upon closer inspection, the following line
was the culprit:
<dtml-in "REQUEST.form['street'].keys()">
Upon even closer inspection, *none* of the dictionary functions would
work. Not even <dtml-var "REQUEST.form['street']['address1']">
Then I decided it was time to just see exactly what was in the object.
<dtml-var "REQUEST.form['street']"> yielded the following results
(I had just entered sequential numbers for all five inputs):
address1: 1, address2: 2, city: 3, state: 4, zip: 5
Here's the output of <dtml-var "REQUEST.form">:
{'street': address1: 1, address2: 2, city: 3, state: 4, zip: 5, 'submit':
'submit'}
The original <dtml-with> code still works, as does
<dtml-var "street.address1">. I've also tried using getitem:
<dtml-var "_.getitem('street')['address1']">
I'm quite confused. It would appear that "street" really *isn't*
a dictionary at all, yet somehow the <dtml-xxx> tags still work. What's
going on here? I'm quite befuddled.
Thanks a lot in advance for any help, and apologies again for the
convoluted message.
-CJ