[Zope] Building a list programmatically under DTML

Martijn Pieters mj@antraciet.nl
Tue, 07 Sep 1999 11:48:10 +0200


At 11:24 07/09/99 , Rik Hoekstra wrote:
>To set things straight: dictionaries are not allowed as variables in dtml -
>they result in syntax errors. In fact Martijn himself :-\ suggested
>alternatives for dictionaries in
>http://www.zope.org/pipermail/zope/1999-August/009166.html

And straight again =):

They are not supported as properties on a properties tab. That was what my 
post was about. In the post I actually create a dictionary in DTML and 
return it, as a solution to the lack of support in the property interface.

But, you can't change a dictionary after creating it.

The following works:

   <dtml-var standard_html_header>

   A little test:

   <dtml-call "REQUEST.set('dict', {'test': 1})">
   <dtml-var "dict['test']">

   <dtml-var standard_html_footer>

But as soon as you want to add:

   <dtml-var "dict['test'] = 2">

Zope's parser throws a tantrum. Assignments are not allowed.

I also tested the append method on lists:

   <dtml-var standard_html_header>

   A little test:

   <dtml-call "REQUEST.set('list', [])">
   <dtml-call "list.append(1)">
   <dtml-var "list[0]">

   <dtml-var standard_html_footer>

Works just fine.

--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-7502100 Fax: +31-35-7502111
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------