Back to index

plone3  3.1.7
sortObjects.py
Go to the documentation of this file.
00001 ## Script (Python) "sortObject"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=contents, method='title_or_id'
00008 ##title=sorts and pre-filters objects
00009 ##
00010 def get_sortable(o):
00011     val = getattr(o, method)()
00012     try:
00013         val = val.lower()
00014     except AttributeError:
00015         pass
00016     return val
00017 
00018 aux = [(get_sortable(o), o) for o in contents]
00019 aux.sort()
00020 return [x[1] for x in aux]