[Erp5-report] r41203 jm - /erp5/trunk/products/ERP5Type/dynamic/lazy_class.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Dec 7 16:56:20 CET 2010


Author: jm
Date: Tue Dec  7 16:56:20 2010
New Revision: 41203

URL: http://svn.erp5.org?rev=41203&view=rev
Log:
Prevent transaction.commit() from reloading ghost portal types

Note this also fixes TestERP5Type.test_04_CategoryAccessors
A shorter test case would be:

  def test(self):
    self.login()
    self.portal.portal_types.Person.foo = 0
    self.portal.person_module.newContent(portal_type='Person')
    transaction.abort()
    self.portal.portal_types.Person.foo = 0
    self.portal.portal_categories.region.newContent()
    self.portal.person_module.newContent(portal_type='Person')
    transaction.commit() # raise ConflictError without this fix

(provided Person portal type does not have 'type_class' attribute at the
 beginning).

Modified:
    erp5/trunk/products/ERP5Type/dynamic/lazy_class.py

Modified: erp5/trunk/products/ERP5Type/dynamic/lazy_class.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/dynamic/lazy_class.py?rev=41203&r1=41202&r2=41203&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/dynamic/lazy_class.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/dynamic/lazy_class.py [utf8] Tue Dec  7 16:56:20 2010
@@ -69,6 +69,9 @@ class GhostBaseMetaClass(ExtensionClass)
     cls.__getattribute__ = __getattribute__
     cls.__init__ = __init__
     cls.__doc__ = GhostBaseMetaClass.ghost_doc
+    # This prevents serialize (ZODB) from reloading the class during commit
+    # (which would even trigger migration, resulting in a ConflictError).
+    cls.__getnewargs__ = None
 
 InitGhostBase = GhostBaseMetaClass('InitGhostBase', (ERP5Base,), {})
 



More information about the Erp5-report mailing list