What follows the = in the dtml-let tag must be either the name of a variable visible in the current namespace, or a python expression. In your <dtml-let x=5>, Zope is trying to find a variable named 5 and assign its value to x. Zope can't find a variable named 5, hence the KeyError. You need to use <dtml-let x="5"> so that the python expression 5 (an integer) is assigned to x. Likewise for y. Note too that, when you assign a string to a variable using dtml-let, you need to use two sets of quotes, e.g. <dtml-let foo="'bar'">, so that the python expression returns 'bar' (a string). -- Marcus
-----Original Message----- From: Michiel Toneman [mailto:toneman@phil.uu.nl] Sent: 29 February 2000 11:44 To: zope@zope.org Subject: [Zope] Newbie: Why doesn't this work?
Hi All,
After struggling with Zope for two weeks now, I still can't figure some things out... From the namespaces HOWTO:
--------------------------------------------------------------- Example: The Let Tag
The Let tag let's you initialize and push a new name space onto the name space stack. The arguments to the Let Tag are evaluated and placed into the top most name space. For example:
<dtml-let x=5 y=7> <dtml-var x><dtml-var y> </dtml-let>
The let tag creates a new name space, enters the integers x and y into the new name space, and pushes the name space onto the stack. ----------------------------------------------------------------
Well, it just doesn't work! I get:
Error Type: KeyError Error Value: 5
I've also tried
<dtml-let x=5 y=7> <dtml-var x><dtml-var y> </dtml-let>
just to be sure...
Also from the namespaces howto:
---------------------------------------------------------------------- Example: The In Tag
A common sight in DTML is iterating over the contents of a Folder. Create a folder called MyFolder and a DTML Method called MyMethod containing the following:
<dtml-in objectValues> <dtml-var id> </dtml-in>
Before entering the block, id was bound to MyFolder. When the block is entered, a new name space is popped onto the name space stack. The new name space contains the name space of the sequence-item in the tag. Because new name spaces override old ones, the new 'sequence-item's id attribute is printed in our example instead of MyFolder.
DTML tags push and pop name spaces onto the stack. Some DTML tags, like and , do not change the name space at all, but , and modify the name space stack in their own way.
The tag pushes the current sequence-item onto the name space stack and then pops it off the stack when the end of the tag is reached. In each iteration through the sequence objectValues, the id of each item in the sequence is rendered ----------------------------------------------------------------------
This doesn't give me anything (yes, there are things in a folder below)
So what am I doing wrong, am i a user=id10t or is something seriously screwy with Zope? I can get a lot of stuff to work, but it's all slow trial and error, because I can't figure out the logic (and apparently neither could the namespaces HOWTO author :( )
Please help,
Michiel Toneman
-- From a Sun Microsystems bug report (#4102680): "Workaround: don't pound on the mouse like a wild monkey."
_______________________________________________ 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 )