[ZPT] tal:repeat over the sorted keys of a dictionary

Jean Jordaan jean at upfrontsystems.co.za
Fri Jul 25 13:13:25 EDT 2003


Hi Tino

> sort() is an in-place operation.

Yeah, I knew this was what I'm facing. Ah, you kickstarted my
brain :)  Looks like this works::

        <ul tal:define="keys licenses/keys; dummy keys/sort"
            tal:repeat="key keys">
            <li tal:content="python:licenses[key]" />
        </ul>

That "dummy" isn't pretty. More natural idioms would be welcomed.

> In your python script which calculates the dictionary,

I'm reluctant to do that. I'm iterating over a ComputedAttribute,
which is supposed to be a dictionary. I don't really want to 
define another method just to pre-iterate the dict.

Thanks!
-- 
Jean Jordaan
http://www.upfrontsystems.co.za




More information about the ZPT mailing list