[Zope] Dynamic dictionary keys?

Jonathan dev101 at magma.ca
Mon Feb 27 12:05:38 EST 2006

----- Original Message ----- 
From: "Andrew Hedges" <andrew at clearwired.com>
To: <zope at zope.org>
Sent: Monday, February 27, 2006 11:56 AM
Subject: [Zope] Dynamic dictionary keys?

> Allow me to preface this by saying I am a complete newbie to Zope (I  
> prefer to think of it as beginner's mind...).  What I am attempting  
> to do is dynamically add items to a dictionary, but Zope complains  
> "keyword can't be an expression".  Here's the reduced case of my code:
> <dtml-let eventsDict="{}">
>    <dtml-let calstart="somestring">
>       <dtml-call "REQUEST.set(eventsDict[calstart]=id)">
>    </dtml-let>
> </dtml-let>

It is much easier in python script, but if you really want to use dtml:

 <dtml-call "REQUEST.set('eventsDict', {})">
 <dtml-call "eventsDict.update({'calstart' : id})">



More information about the Zope mailing list