Commit d3b96d4c authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

use sort_order as the part of the cache key.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24118 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 870fa72f
...@@ -76,10 +76,8 @@ def sortValueList(value_list, sort_on=None, sort_order=None, **kw): ...@@ -76,10 +76,8 @@ def sortValueList(value_list, sort_on=None, sort_order=None, **kw):
# try to cache keyword arguments for sort() # try to cache keyword arguments for sort()
sort_on = tuple([isinstance(x, str) and x or tuple(x) for x in sort_on]) sort_on = tuple([isinstance(x, str) and x or tuple(x) for x in sort_on])
try: try:
sort_kw = sort_kw_cache[sort_on] sort_kw = sort_kw_cache[(sort_on, sort_order)]
if sort_order is not None: except (KeyError, TypeError):
sort_kw["reverse"] = (sort_order in ('descending', 'reverse', 'DESC'))
except KeyError:
new_sort_on = [] new_sort_on = []
reverse_dict = {} reverse_dict = {}
for key in sort_on: for key in sort_on:
...@@ -126,7 +124,7 @@ def sortValueList(value_list, sort_on=None, sort_order=None, **kw): ...@@ -126,7 +124,7 @@ def sortValueList(value_list, sort_on=None, sort_order=None, **kw):
value_list.append(x) value_list.append(x)
return value_list return value_list
sort_kw = {'key':sortValue, 'reverse':reverse} sort_kw = {'key':sortValue, 'reverse':reverse}
sort_kw_cache[sort_on] = sort_kw sort_kw_cache[(sort_on, sort_order)] = sort_kw
else: else:
# otherwise we use sort(cmp=func). # otherwise we use sort(cmp=func).
def sortValues(a, b): def sortValues(a, b):
...@@ -147,7 +145,7 @@ def sortValueList(value_list, sort_on=None, sort_order=None, **kw): ...@@ -147,7 +145,7 @@ def sortValueList(value_list, sort_on=None, sort_order=None, **kw):
break break
return result return result
sort_kw = {'cmp':sortValues} sort_kw = {'cmp':sortValues}
sort_kw_cache[sort_on] = sort_kw sort_kw_cache[(sort_on, sort_order)] = sort_kw
if isinstance(value_list, LazyMap): if isinstance(value_list, LazyMap):
new_value_list = [x for x in value_list] new_value_list = [x for x in value_list]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment