HI I'd like to put a % sign before and after the values of the form variables with a loop and keep the changed form varibles in the REQUEST object. How can it be? Halinux
Horvath Adam wrote:
I'd like to put a % sign before and after the values of the form variables with a loop and keep the changed form varibles in the REQUEST object. How can it be?
why? however (untested) <dtml-in "REQUEST.form.items()"> <dtml-let i="_['sequence-item']" k="i[0]" v="i[1]"
<dtml-call "REQUEST.form.update( k, { k: '%' + _.str(v) + '%' } )"> ------------------------------------------------------------- Who's got only a hammer sees the world as a nail hans augustin (software developer) hans@beehive.de beehive elektronische medien GmbH http://www.beehive.de phone: +49 30 847-82 0 fax: +49 30 847-82 299
A bit simpler and fixed for a bug: <dtml-in "REQUEST.form.items()" prefix=loop> <dtml-call "REQUEST.form.update({ loop_key: '%'+_.str(loop_item)+'%' })"> or <dtml-call "REQUEST.form.update({ loop_key: '%%%s%%' % loop_item })"> </dtml-in> prefix="xxx" isn't a widely known feature of dtml-in; it allows you to pick a prefix for looping variables, and lets you avoid ugliness like _['sequence-item']. for a mapping {'a':'apple', 'b':'bear'}, a.items() returns (('a','apple'),('b','bear')) for each iteration of the dtml-in, this becomes _key='a', _item='apple', etc. If you don't use the prefix= trick, these would be sequence-key and sequence-item, but then you have the icky hyphen problem. a_mapping.update() only takes one argument -- a dictionary; not two, as hans has below. Joel BURTON | joel@joelburton.com | joelburton.com | aim: wjoelburton Knowledge Management & Technology Consultant
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of hans Sent: Monday, March 18, 2002 10:58 AM To: Horvath Adam Cc: zope@zope.org Subject: Re: [Zope] changing form values
Horvath Adam wrote:
I'd like to put a % sign before and after the values of the form variables with a loop and keep the changed form varibles in the REQUEST object. How can it be?
why? however (untested) <dtml-in "REQUEST.form.items()"> <dtml-let i="_['sequence-item']" k="i[0]" v="i[1]"
<dtml-call "REQUEST.form.update( k, { k: '%' + _.str(v) + '%' } )">
Joel Burton wrote:
prefix="xxx" isn't a widely known feature of dtml-in; it allows you to pick a prefix for looping variables, and lets you avoid ugliness like
ahem, sorry for the update-bug (happens when answering quickly) as for the prefix: its well known to me (though out of laziness and i've learned without i don't use it) Whats more, the prefix tag is valid only for zope above some version (can't remember, which, something like 2.3 or so), and THIS (the version specific) IS NOT DOCUMENTED!! If i err, forgive me, can't read docs all day cheers hans -- ------------------------------------------------------------- Who's got only a hammer sees the world as a nail hans augustin (software developer) hans@beehive.de beehive elektronische medien GmbH http://www.beehive.de phone: +49 30 847-82 0 fax: +49 30 847-82 299
participants (3)
-
hans -
Horvath Adam -
Joel Burton