From fbbe6116b1c9ca6f0a535411e66e0d7049d5e977 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Tue, 22 Aug 2006 14:30:43 +0000
Subject: [PATCH] Protect against non-string values in id_generator. This
 should fix most unit test steps in ERP5SyncML.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9327 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/Document/Folder.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/product/ERP5Type/Document/Folder.py b/product/ERP5Type/Document/Folder.py
index 5d19ce959e..73f2d78683 100644
--- a/product/ERP5Type/Document/Folder.py
+++ b/product/ERP5Type/Document/Folder.py
@@ -154,15 +154,19 @@ class FolderMixIn(ExtensionClass.Base, CopyContainer):
     if id_group is None:
       id_group = self.getIdGroup()
     if id_group in (None, 'None'):
-      idGenerator = getattr(self, self.getIdGenerator(), None)
-      if idGenerator is None:
+      id_generator = self.getIdGenerator()
+      if isinstance(id_generator, str):
+        idGenerator = getattr(self, id_generator, None)
+        if idGenerator is None:
+          idGenerator = self._generateNextId
+      else:
+        LOG('Folder.generateNewId', 0, '%s.id_generator is not a string. Falling back on default behaviour.' % (self.absolute_url(), ))
         idGenerator = self._generateNextId
       my_id = idGenerator()
       while self.hasContent(my_id):
         my_id = _generateNextId()
     else:
       my_id = str(self.portal_ids.generateNewId(id_group=id_group,default=default,method=method))
-
     return my_id
 
   security.declareProtected(Permissions.View, 'hasContent')
-- 
2.30.9