On Tue, 11 Jul 2000, Marcel Preda wrote:
Greetings,
This seems like it should be a simple thing.... but I can't seem to find how to make dtml-in behave with maps. In particular, empty maps.
I've tried mapping, i've tried testing _.len(map.keys()), and various other things. But it always fails, telling me Error Type: KeyError Error Value: 0
What am I missing?
Have a better one, Curtis.
looks like the variable that you are using in <dtml-in ...> is noat a sequence (list || tuple)
I suppose that your var is a dictionary
Well.. this is where things start to get fun. (o8 I have a dirty great array.... along the lines of : [ [ 'string', 0, { 'name':'value' } ], [ 'string', 0, { 'name':'value' } ] ] (I love python.. the same thing in C/C++ would take HEAPS of work :) So, I iterate over the array... that's working fine... Then, for each iteration, I handle the data however... I wind up with: <dtml-in "_['sequence-item'][2]"> <!-- do stuff here --> </dtml-in> But that's where the problem begins.
Insted of : <dtml-in x mapping> you have to use: <dtml-in "[x]" mapping> as a list
<dtml-in "(x,)" mapping> as a tuple
So, you're saying that by creating a list with one element which is a dictionary... ?
PM
Have a better one, Curtis.