From 99f3b3c64195a1d7f6375c9097d3966516fbafff Mon Sep 17 00:00:00 2001 From: Sebastien Robin <seb@nexedi.com> Date: Mon, 21 Feb 2011 17:31:53 +0000 Subject: [PATCH] make the migration tolerant to existing bad references git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43533 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/mixin/id_as_reference.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/product/ERP5Type/mixin/id_as_reference.py b/product/ERP5Type/mixin/id_as_reference.py index e055360839..4ec1475bb7 100644 --- a/product/ERP5Type/mixin/id_as_reference.py +++ b/product/ERP5Type/mixin/id_as_reference.py @@ -29,6 +29,7 @@ import transaction from AccessControl import ClassSecurityInfo from Products.ERP5Type import Permissions, PropertySheet +from zLOG import LOG, WARNING def IdAsReferenceMixin(suffix): suffix_index = - len(suffix) @@ -43,7 +44,14 @@ def IdAsReferenceMixin(suffix): def __migrate(self): if self.id[suffix_index:] != suffix: - self.setId(self.__dict__.pop('default_reference') + suffix) + new_id = self.__dict__.get('default_reference') + suffix + parent = self.getParentValue() + if parent.has_key(new_id): + LOG("IdAsReferenceMixin", WARNING, "Skipping migration of %r in %r" + " property sheet, due to ID conflict" % (new_id, parent.getId())) + else: + del self.default_reference + self.setId(new_id) security.declareProtected(Permissions.AccessContentsInformation, 'getReference') -- 2.30.9