I'd like to sort the items in a folder by relevance, relevance being a
property I've assigned.
I'm using a python script
for aj in
ao.objectItems(items):
aao=aj[1] #the
object
title=aao.title
id=aj[0]
aanum=len(aao.objectIds())
if ( aanum >
1 ):
if
(title != '' and id != 'index_html' and not o.hasProperty('display')):
ret=ret # +"
<li id=ul_"+id+">"
else:
if
(title != '' and id != 'index_html' and not o.hasProperty('display')):
ret=ret # +" <li
id=ul_"+id+" class=closed1>"
if (title != ''
and id != 'index_html' and not o.hasProperty('display')):
ret=ret+"<li id=ul_"+id+"><h3><a
href=\""+aao.absolute_url()+"\"> "+title+"</a></h3></li>\n"
…
When I try
values=ao.objectItems(items)
values.sort(lambda a,b:
cmp(a[0],b[0]))
for aj in values:
aao=aj[1] #the
object
title=aao.title
Error
Type: AttributeError
Error Value: 'tuple' object has no attribute 'sort'
Obviously,
id isn’t really what I wanted to sort by anyway but since I can’t
even do that I can’t really go on to try to
use getattr
to try and sort on relevance….
Kate
The full
trackback in case anyone wants it is….
Traceback (innermost last): Module ZPublisher.Publish, line 115, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 41, in call_object Module OFS.DTMLDocument, line 128, in __call__ - <DTMLDocument at /kfplsite/redesign/aboutLibrary/index_html>- URL: http://www2.kfpl.ca:8080/kfplsite/redesign/aboutLibrary/index_html/manage_main
- Physical Path: /kfplsite/redesign/aboutLibrary/index_html
Module DocumentTemplate.DT_String, line 476, in __call__ Module OFS.DTMLDocument, line 121, in __call__ - <DTMLDocument at /kfplsite/redesign/menuLeft used for /kfplsite/redesign/aboutLibrary>- URL: http://www2.kfpl.ca:8080/kfplsite/redesign/menuLeft/manage_main
- Physical Path: /kfplsite/redesign/menuLeft
Module DocumentTemplate.DT_String, line 476, in __call__ Module OFS.DTMLMethod, line 137, in __call__ - <DTMLMethod at /kfplsite/redesign/pythonLeftMenu used for /kfplsite/redesign/menuLeft>- URL: http://www2.kfpl.ca:8080/kfplsite/redesign/pythonLeftMenu/manage_main
- Physical Path: /kfplsite/redesign/pythonLeftMenu
Module DocumentTemplate.DT_String, line 476, in __call__ Module DocumentTemplate.DT_Util, line 196, in eval - __traceback_info__: redesign Module <string>, line 1, in <expression> Module Shared.DC.Scripts.Bindings, line 311, in __call__ Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec Module Products.PythonScripts.PythonScript, line 323, in _exec Module None, line 65, in pythonLeftMenuKatie2 - <PythonScript at /kfplsite/redesign/pythonLeftMenuKatie2 used for /kfplsite/redesign/menuLeft> - Line 65AttributeError: 'tuple' object has no attribute 'sort'