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... The dictionaries all have a 'title' entry (I checked) so it looks like sequence.sort has some sort of requirements for its data list. Is there a better way to do this? TIA, - rmgw <http://www.trustedmedianetworks.com/> ---------------------------------------------------------------------------- Richard Wesley Trusted Media Networks, Inc. "...if you can't get out, you just either blow something up, or you eat something, or you just throw penguins in the air." - Brian Henson
Is there a better way to do this?
Your subject is misleading. From what I can tell, you don't want to sort a dictionary. You want to sort a list of dictionaries by a particular key that all of the dictionaries have, true? Why not make a Python script that does what you want and call *that* from ZPT? Cheers, // m -
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
participants (3)
-
Dieter Maurer -
Mark McEahern -
Richard Wesley