From 49e44d186ebc6be736e19fc47021f41d5e15d7c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Mon, 22 Oct 2007 08:22:32 +0000
Subject: [PATCH] fix call of HBTree method when using a base_id parameter to
 avoid confusing between None and marker add test for this

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17078 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/Core/Folder.py               | 23 +++++++++++++------
 product/ERP5Type/tests/testFolderMigration.py |  8 ++++++-
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/product/ERP5Type/Core/Folder.py b/product/ERP5Type/Core/Folder.py
index 6479658cc6..fc526e04fb 100644
--- a/product/ERP5Type/Core/Folder.py
+++ b/product/ERP5Type/Core/Folder.py
@@ -746,21 +746,27 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
     else:
       return CMFBTreeFolder._checkObjectId(self, id)
 
-  def objectIds(self, spec=None, base_id=None):
+  def objectIds(self, spec=None, **kw):
     if self._folder_handler == HBTREE_HANDLER:
       if self._htree is None:
         return []
-      return CMFHBTreeFolder.objectIds(self, base_id)
+      if kw.has_key("base_id"):
+        return CMFHBTreeFolder.objectIds(self, base_id=kw["base_id"])
+      else:
+        return CMFHBTreeFolder.objectIds(self)
     else:
       if self._tree is None:
         return []
       return CMFBTreeFolder.objectIds(self, spec)
 
-  def objectItems(self, spec=None, base_id=None):
+  def objectItems(self, **kw):
     if self._folder_handler == HBTREE_HANDLER:
       if  self._htree is None:
         return []
-      return CMFHBTreeFolder.objectItems(self, base_id)
+      if kw.has_key("base_id"):
+        return CMFHBTreeFolder.objectItems(self, base_id=kw["base_id"])
+      else:
+        return CMFHBTreeFolder.objectItems(self)
     else:
       if  self._tree is None:
         return []
@@ -1352,8 +1358,8 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
   security.declareProtected( Permissions.AccessContentsInformation,
                              'objectValues' )
   def objectValues(self, spec=None, meta_type=None, portal_type=None,
-                   sort_on=None, sort_order=None, base_id=None,
-                   checked_permission=None, **kw):
+                   sort_on=None, sort_order=None, checked_permission=None,
+                   **kw):
     # Returns list of objects contained in this folder.
     #  (no docstring to prevent publishing)
 
@@ -1372,7 +1378,10 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
       if self._htree is None:
         object_list = []
       else:
-        object_list = CMFHBTreeFolder.objectValues(self, base_id=base_id)
+        if kw.has_key("base_id"):
+          object_list = CMFHBTreeFolder.objectValues(self, base_id=kw['base_id'])
+        else:
+          object_list = CMFHBTreeFolder.objectValues(self)
     else:
       if self._tree is None:
         object_list = []
diff --git a/product/ERP5Type/tests/testFolderMigration.py b/product/ERP5Type/tests/testFolderMigration.py
index 1b7ce0c483..0b4e373c11 100755
--- a/product/ERP5Type/tests/testFolderMigration.py
+++ b/product/ERP5Type/tests/testFolderMigration.py
@@ -114,7 +114,13 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
       self.assertEqual(self.folder.isBTree(), False)
       self.assertEqual(self.folder.isHBTree(), True)
       self.assertEqual(len(self.folder.getTreeIdList()), 1)
-      self.assertEqual(len(self.folder.objectIds()), 3)      
+      self.assertEqual(len(self.folder.objectIds()), 3)
+      # check params of objectIds in case of hbtree
+      self.assertEqual(len(self.folder.objectIds(base_id=None)), 0)
+      LOG("test", 300, "rien")
+      self.assertEqual(len(self.folder.objectValues()), 3)
+      LOG("test", 300, "base_id")
+      self.assertEqual(len(self.folder.objectValues(base_id=None)), 0)
       # check object ids
       from DateTime import DateTime
       date = DateTime().Date()
-- 
2.30.9