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) + '%' } )">