All, I'm having a silly syntax problem again, and I can't get it right. I'm try to update a value in a list DetailBodyHeader at Index DetailEditSection with the value in the variable BodyText. The following statement executes without error, but doesn't update the value: dtml-call "REQUEST.set('DetailBodyHeader[DetailEditSection]',BodyHeader)" Can someone point me in the right direction? Many thanks, Jeff
Hi Jeff, Jeff Nielsen wrote:
All,
I’m having a silly syntax problem again, and I can’t get it right. I’m try to update a value in a list DetailBodyHeader at Index DetailEditSection with the value in the variable BodyText. The following statement executes without error, but doesn’t update the value:
dtml-call "REQUEST.set('DetailBodyHeader[DetailEditSection]',BodyHeader)"
Can someone point me in the right direction?
thats easy :-) I always recommend starting the interpeter in a window and try out interactively the things described in the python tutorial (in your distribution or on www.python.org ->Documentaton->Tutorial) It should not take more then 2hours and helps you to avoid such erm.. nonsense like above :-) All you need to know is REQUEST works like a mapping (python dictionary). dbh=REQUEST.get('DetailBodyHeader') dbh[DetailEditSection]=BodyHeader RQUEST.set('DetailBodyHeader',dbh) # this could be ommited due to the "in place" modification, but should not if you want to use this method elsewhere in Zope, on a persistent object for example. Regards Tino Wildenhain
Tino Wildenhain wrote:
RQUEST.set('DetailBodyHeader',dbh) # this could be ommited due to the "in place" modification, but should not if you want to use this method elsewhere in Zope, on a persistent object for example.
And for bonus points, quit using DTML and start using Python Scripts... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (3)
-
Chris Withers -
Jeff Nielsen -
Tino Wildenhain