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.
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 Insted of : <dtml-in x mapping> you have to use: <dtml-in "[x]" mapping> as a list || <dtml-in "(x,)" mapping> as a tuple PM _______________________________ "Will I be using Python today?" and if the answer is "yes" I know that it's going to be a good day.
On Tue, 11 Jul 2000, Marcel Preda wrote:
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
Insted of : <dtml-in x mapping> you have to use: <dtml-in "[x]" mapping> as a list || <dtml-in "(x,)" mapping> as a tuple
Note that this gives you one iteration of the dtml-in, with (if I understand this right) x pushed on the namespace stack as another dictionary to look things up in. --RDM
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.
----- Original Message ----- From: Curtis Maloney <curtis@umd.com.au>
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.
Yes in did the "_['sequence-item'][2]" is a dictionary. You can do like <dtml-in "[_['sequence-item'][2]]"> <!-- do stuff here --> </dtml-in> (untested :0) but why not without <dtml-in> ... <!-- do stuff here with "_['sequence-item'][2]['name']"--> PM
participants (3)
-
Curtis Maloney -
Marcel Preda -
R. David Murray