[Erp5-report] r44449 kazuhiko - /erp5/trunk/products/ERP5Type/id_as_reference.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Mar 18 23:47:09 CET 2011


Author: kazuhiko
Date: Fri Mar 18 23:47:09 2011
New Revision: 44449

URL: http://svn.erp5.org?rev=44449&view=rev
Log:
IdAsReferenceMixin.getReference() is called even in portal_property_sheets migration, so we need a backward compatibility code here, otherwise we cannot safely update 'somehow migrated' instance.

Modified:
    erp5/trunk/products/ERP5Type/id_as_reference.py

Modified: erp5/trunk/products/ERP5Type/id_as_reference.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/id_as_reference.py?rev=44449&r1=44448&r2=44449&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/id_as_reference.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/id_as_reference.py [utf8] Fri Mar 18 23:47:09 2011
@@ -31,6 +31,7 @@ from AccessControl import ClassSecurityI
 from Products.ERP5Type import Permissions, PropertySheet
 from Products.CMFActivity.Errors import ActivityPendingError
 from zLOG import LOG, WARNING
+from Acquisition import aq_base
 
 def IdAsReferenceMixin(suffix):
   suffix_index = - len(suffix)
@@ -71,6 +72,9 @@ def IdAsReferenceMixin(suffix):
       id = self.id
       if id[suffix_index:] == suffix:
         return id[:suffix_index]
-      return self._baseGetReference(*args)
+      try:
+        return self._baseGetReference(*args)
+      except AttributeError:
+        return getattr(aq_base(self), 'default_reference', (args or [None])[0])
 
   return IdAsReferenceMixin



More information about the Erp5-report mailing list