Commit 2fcda5b2 authored by Aurel's avatar Aurel

check that the ID generated is valid, if not fallback to default generator

parent d2e055cf
...@@ -32,7 +32,8 @@ from collections import deque ...@@ -32,7 +32,8 @@ from collections import deque
from AccessControl import ClassSecurityInfo, getSecurityManager from AccessControl import ClassSecurityInfo, getSecurityManager
from AccessControl.ZopeGuards import NullIter from AccessControl.ZopeGuards import NullIter
from Acquisition import aq_base, aq_parent, aq_inner from Acquisition import aq_base, aq_parent, aq_inner
from OFS.ObjectManager import ObjectManager from OFS.ObjectManager import ObjectManager, checkValidId
from zExceptions import BadRequest
from OFS.History import Historical from OFS.History import Historical
import ExtensionClass import ExtensionClass
...@@ -216,13 +217,18 @@ class FolderMixIn(ExtensionClass.Base): ...@@ -216,13 +217,18 @@ class FolderMixIn(ExtensionClass.Base):
def _generatePerNodeId(self): def _generatePerNodeId(self):
""" """
Generate id base on node-id defined in zope.conf, Generate id base on the node id defined in the zope.conf,
useful for import and mass creation useful for import and mass creation
of objects inside a module using activities of objects inside a module using activities
We also append random id We also append random id
""" """
activity_tool = self.getPortalObject().portal_activities activity_tool = self.getPortalObject().portal_activities
return "%s-%s" %(activity_tool.getCurrentNode(), self._generateRandomId()) new_id = "%s-%s" %(activity_tool.getCurrentNode(), self._generateRandomId())
try:
checkValidId(new_id)
except BadRequest:
return self._generateNextId()
return new_id
def _generatePerNodeNumberId(self): def _generatePerNodeNumberId(self):
""" """
......
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