Nested list with TAL

114 views Asked by At

I'm using Chameleon in the Pyramids Framework and want to repeat nested list while rendering the template.

My minimized HTML-Code is:

1. <ul>
2.  <li tal:repeat="item items">
3.      <input tal:attributes="id item.id; onclick item.url">
4.      <label tal:repeat="premise item.values" tal:attributes="for item.id; id premise.id">
5.          <label tal:replace="premise.title"/>
6.      </label>
7.      <label tal:attributes="for item.id" tal:content="item.title"/>
8.  </li>
9. </ul>

Whereby I got the following json-Data

[{
    'url': 'location.href="http://..."',
    'values':
    [{
        'id': '70',
        'title': 'some title 1'
    }],
    'attitude': 'justify', 
    'id': '68',
    'title': 'some title 2'
}, {
    'url': 'null',
    'values':
    [{
        'id': '0',
        'title': 'some title 3!
    }],
    'attitude': 'justify',
    'id': '0',
    'title':
    'some title 4'
}]

If I kill HTML-lines 4.-6., everything is fine, otherwise Pyramid/Chameleon throws:

  File "/usr/local/lib/python3.4/dist-packages/chameleon/tal.py", line 471, in __call__
    iterable = list(iterable) if iterable is not None else ()
TypeError: 'builtin_function_or_method' object is not iterable

Anyone some idea?

1

There are 1 answers

0
Tobias S On BEST ANSWER

Thanks to #pyramid in the IRC i got the first hint, which is mentioned in the comment. But..never ever name a key 'value' or 'values'!