Commit fbbe6116 authored by Vincent Pelletier's avatar Vincent Pelletier

Protect against non-string values in id_generator. This should fix most unit...

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
parent 81b33b8d
...@@ -154,15 +154,19 @@ class FolderMixIn(ExtensionClass.Base, CopyContainer): ...@@ -154,15 +154,19 @@ class FolderMixIn(ExtensionClass.Base, CopyContainer):
if id_group is None: if id_group is None:
id_group = self.getIdGroup() id_group = self.getIdGroup()
if id_group in (None, 'None'): if id_group in (None, 'None'):
idGenerator = getattr(self, self.getIdGenerator(), None) id_generator = self.getIdGenerator()
if idGenerator is None: 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 idGenerator = self._generateNextId
my_id = idGenerator() my_id = idGenerator()
while self.hasContent(my_id): while self.hasContent(my_id):
my_id = _generateNextId() my_id = _generateNextId()
else: else:
my_id = str(self.portal_ids.generateNewId(id_group=id_group,default=default,method=method)) my_id = str(self.portal_ids.generateNewId(id_group=id_group,default=default,method=method))
return my_id return my_id
security.declareProtected(Permissions.View, 'hasContent') security.declareProtected(Permissions.View, 'hasContent')
......
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