[Erp5-report] r24118 - /erp5/trunk/products/ERP5Type/Utils.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Oct 9 13:39:12 CEST 2008


Author: kazuhiko
Date: Thu Oct  9 13:39:04 2008
New Revision: 24118

URL: http://svn.erp5.org?rev=24118&view=rev
Log:
use sort_order as the part of the cache key.

Modified:
    erp5/trunk/products/ERP5Type/Utils.py

Modified: erp5/trunk/products/ERP5Type/Utils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Utils.py?rev=24118&r1=24117&r2=24118&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Utils.py (original)
+++ erp5/trunk/products/ERP5Type/Utils.py Thu Oct  9 13:39:04 2008
@@ -76,10 +76,8 @@
     # try to cache keyword arguments for sort()
     sort_on = tuple([isinstance(x, str) and x or tuple(x) for x in sort_on])
     try:
-      sort_kw = sort_kw_cache[sort_on]
-      if sort_order is not None:
-        sort_kw["reverse"] = (sort_order in ('descending', 'reverse', 'DESC'))
-    except KeyError:
+      sort_kw = sort_kw_cache[(sort_on, sort_order)]
+    except (KeyError, TypeError):
       new_sort_on = []
       reverse_dict = {}
       for key in sort_on:
@@ -126,7 +124,7 @@
             value_list.append(x)
           return value_list
         sort_kw = {'key':sortValue, 'reverse':reverse}
-        sort_kw_cache[sort_on] = sort_kw
+        sort_kw_cache[(sort_on, sort_order)] = sort_kw
       else:
         # otherwise we use sort(cmp=func).
         def sortValues(a, b):
@@ -147,7 +145,7 @@
               break
           return result
         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):
       new_value_list = [x for x in value_list]




More information about the Erp5-report mailing list