[Zope] Sorting a dictionary in ZPT
Dieter Maurer
dieter@handshake.de
Wed, 12 Feb 2003 20:27:46 +0100
Richard Wesley wrote at 2003-2-11 09:54 -0800:
> I have a list of dictionaries extracted from a database by a python
> script. I would like to sort them for display in a ZPT. When I try
> to say something like
>
> tal:define="raw python:here.rawScript();
> cooked python:sequence.sort(raw,(('title','nocase','asc'),));"
>
> I get the rather annoying error message:
>
> Error Type: TALESError
> Error ValueL exceptions.AttributeError on 'None' object has no
> attribute 'lower' in <PythonExpr
> sequence.sort(raw,(('title','nocase','asc'),))>, at line...
"sort" expects that the "column names" in your sort specification
can be interpreted as attributes.
When you want to sort a sequence of dictionaries, your must
pass "mapping=1" to "sort".
Dieter