[Zope] Getting at form variables
Shalabh Chaturvedi
shalabh@pspl.co.in
Fri, 26 Nov 1999 18:23:58 +0530
| > 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.
Yes it does work (except when unlike `key`, the name has a hyphen - eg.
`sequence-index`):-
<dtml-var "REQUEST[squence-index]"> doesn't work.
Probably gets evaluated as sequence - index ('-' = subract).
(These little gotchas!)
But this achieves the same:-
<dtml-let si=sequence-index>
<dtml-var "REQUEST[si]">
~Shalabh
----- Original Message -----
From: Duncan Booth <duncan@rcp.co.uk>
To: Shalabh Chaturvedi <shalabh@pspl.co.in>; zope <Zope@zope.org>
Sent: Friday, November 26, 1999 2:58 PM
Subject: Re: [Zope] Getting at form variables
| > 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