[Erp5-report] r43533 seb - /erp5/trunk/products/ERP5Type/mixin/id_as_reference.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Feb 21 18:31:54 CET 2011
Author: seb
Date: Mon Feb 21 18:31:53 2011
New Revision: 43533
URL: http://svn.erp5.org?rev=43533&view=rev
Log:
make the migration tolerant to existing bad references
Modified:
erp5/trunk/products/ERP5Type/mixin/id_as_reference.py
Modified: erp5/trunk/products/ERP5Type/mixin/id_as_reference.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/mixin/id_as_reference.py?rev=43533&r1=43532&r2=43533&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/mixin/id_as_reference.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/mixin/id_as_reference.py [utf8] Mon Feb 21 18:31:53 2011
@@ -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')
More information about the Erp5-report
mailing list