[Zope] Getting at form variables

Duncan Booth duncan@rcp.co.uk
Fri, 26 Nov 1999 09:28:43 +0000


> I wanted that a url of the form 'http://url?a=b+c&d=e'
> produce a page like:
> 
> [----desired-webpage----
> You submitted:
>   a = b c
>   d = e
> ---------------------------]
> 
> I have finally found the following way to do it:-
> 
... code snipped ...
> Is there a neater/better way?
You submitted:<br>
<dtml-in "REQUEST.form.items()">
<dtml-var sequence-key> = <dtml-var sequence-item><br>
</dtml-in>  

The items() method on a dictionary lets the in tag handle the key 
and the value together.

> More generally, given a dictionary called map and a string called
> key... 
> 
> <dtml-var map>   prints `{a: 'b c', d: 'e' }`
> <dtml-var key>    prints  `a`
> 
> ...is there a way to get at map[key] through DTML ?
> (`b c` in the above example)
> 
> <dtml-var map[<dtml-var key>]> doesn't work.

<dtml-var "map[key]"> should work though.


-- 
Duncan Booth                                             duncan@dales.rmplc.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan