[Erp5-report] r14670 - in /erp5/trunk/products/CMFCategory: ./ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Jun 1 17:03:00 CEST 2007


Author: jerome
Date: Fri Jun  1 17:03:00 2007
New Revision: 14670

URL: http://svn.erp5.org?rev=14670&view=rev
Log:
local_sort_id and local_sort_method were not passed recursivly, so only the
first level was sorted correctly (and the test was also wrong).


Modified:
    erp5/trunk/products/CMFCategory/Category.py
    erp5/trunk/products/CMFCategory/tests/testCMFCategory.py

Modified: erp5/trunk/products/CMFCategory/Category.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFCategory/Category.py?rev=14670&r1=14669&r2=14670&view=diff
==============================================================================
--- erp5/trunk/products/CMFCategory/Category.py (original)
+++ erp5/trunk/products/CMFCategory/Category.py Fri Jun  1 17:03:00 2007
@@ -254,8 +254,8 @@
       
       child_value_list = self.objectValues(self.allowed_types)
       if local_sort_id:
-        local_sort_method = lambda a, b: cmp(a.getProperty(local_sort_id),
-                                             b.getProperty(local_sort_id))
+        local_sort_method = lambda a, b: cmp(a.getProperty(local_sort_id, 0),
+                                             b.getProperty(local_sort_id, 0))
       if local_sort_method:
         # sort objects at the current level
         child_value_list = list(child_value_list)
@@ -715,18 +715,22 @@
 
       child_value_list = self.objectValues(self.allowed_types)
       if local_sort_id:
-        local_sort_method = lambda a, b: cmp(a.getProperty(local_sort_id),
-                                             b.getProperty(local_sort_id))
+        local_sort_method = lambda a, b: cmp(a.getProperty(local_sort_id, 0),
+                                             b.getProperty(local_sort_id, 0))
       if local_sort_method:
         # sort objects at the current level
         child_value_list = list(child_value_list)
         child_value_list.sort(local_sort_method)
+      
+      LOG('self %s' % self, 0, (local_sort_id, local_sort_method))
 
       if recursive:
         for c in child_value_list:
           value_list.extend(c.getCategoryChildValueList(recursive=1,
                                         is_self_excluded=0,
-                                        include_if_child=include_if_child))
+                                        include_if_child=include_if_child,
+                                        local_sort_id=local_sort_id,
+                                        local_sort_method=local_sort_method))
       else:
         for c in child_value_list:
           if include_if_child:

Modified: erp5/trunk/products/CMFCategory/tests/testCMFCategory.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFCategory/tests/testCMFCategory.py?rev=14670&r1=14669&r2=14670&view=diff
==============================================================================
--- erp5/trunk/products/CMFCategory/tests/testCMFCategory.py (original)
+++ erp5/trunk/products/CMFCategory/tests/testCMFCategory.py Fri Jun  1 17:03:00 2007
@@ -879,7 +879,7 @@
     # here c1, c2, c3 are sorted by their int_index
     self.assertEquals(list(bc.getCategoryChildValueList(
                                         local_sort_id='int_index')),
-                      [c1, c11, c111, c12, c3, c2])
+                      [c1, c12, c11, c111, c3, c2])
     # here c11 & c12 are sorted by their titles
     self.assertEquals(list(c1.getCategoryChildValueList(
                               local_sort_id='int_index')), [c12, c11, c111])




More information about the Erp5-report mailing list