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:- [----dtml-snip------------ You submitted: <dtml-in "REQUEST.form.keys()"> <dtml-var sequence-item> = <dtml-var "REQUEST.form[_['sequence-item']]"> <br> </dtml-in> ---------------------------] Is there a neater/better way? 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. Thanks, Shalabh
I found another way too ! <dtml-in "REQUEST.form.keys()"> <dtml-let si=sequence-item> <dtml-var sequence-item> = <dtml-var expr="REQUEST[si]"> </dtml-let> <br> </dtml-in> I don't think variables like sequence-item with a hyphen should be defined by Zope considering that they cannot be used in expressions without renaming them. Shalabh ----- Original Message ----- From: Shalabh Chaturvedi <shalabh@pspl.co.in> To: zope <Zope@zope.org> Sent: Friday, November 26, 1999 12:28 AM Subject: [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:- | | [----dtml-snip------------ | | You submitted: | | <dtml-in "REQUEST.form.keys()"> | <dtml-var sequence-item> = <dtml-var | "REQUEST.form[_['sequence-item']]"> | <br> | </dtml-in> | ---------------------------] | | Is there a neater/better way? 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. | | | Thanks, | Shalabh | | | _______________________________________________ | Zope maillist - Zope@zope.org | http://lists.zope.org/mailman/listinfo/zope | No cross posts or HTML encoding! | (Related lists - | http://lists.zope.org/mailman/listinfo/zope-announce | http://lists.zope.org/mailman/listinfo/zope-dev ) |
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
| > 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
On Fri, 26 Nov 1999, Shalabh Chaturvedi wrote:
| <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]">
<dtml-var "REQUEST[_['squence-index']]"> Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd@phd.russ.ru Programmers don't die, they just GOSUB without RETURN.
participants (3)
-
Duncan Booth -
Oleg Broytmann -
Shalabh Chaturvedi