[Erp5-report] r40754 nicolas.dumazet - /erp5/trunk/products/ERP5Type/dynamic/
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Nov 26 08:27:37 CET 2010
Author: nicolas.dumazet
Date: Fri Nov 26 08:27:37 2010
New Revision: 40754
URL: http://svn.erp5.org?rev=40754&view=rev
Log:
use lock to avoid reloading portal type classes in one thread while
the other one loads them
Modified:
erp5/trunk/products/ERP5Type/dynamic/lazy_class.py
erp5/trunk/products/ERP5Type/dynamic/portal_type_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=40754&r1=40753&r2=40754&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/dynamic/lazy_class.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/dynamic/lazy_class.py [utf8] Fri Nov 26 08:27:37 2010
@@ -159,34 +159,38 @@ class PortalTypeMetaClass(ExtensionClass
raise AttributeError("Could not find a portal type class in"
" class hierarchy")
+ ERP5Base.aq_method_lock.acquire()
portal_type = klass.__name__
try:
- class_definition = generatePortalTypeClass(portal_type)
- except AttributeError:
- LOG("ERP5Type.Dynamic", WARNING,
- "Could not access Portal Type Object for type %r"
- % portal_type, error=sys.exc_info())
- base_list = (ERP5BaseBroken, )
- attribute_dict = {}
- interface_list = []
- else:
- base_list, interface_list, attribute_dict = class_definition
-
-
- # save the old bases to be able to restore a ghost state later
- if klass.__ghostbase__ is None:
- # but only do it if we're in the innermost call, otherwise
- # klass.__bases__ might just be the Document without accessor
- # holders, and we would override the real ghost class
- klass.__ghostbase__ = klass.__bases__
- klass.__bases__ = base_list
-
- for key, value in attribute_dict.iteritems():
- setattr(klass, key, value)
-
- klass.resetAcquisitionAndSecurity()
- for interface in interface_list:
- classImplements(klass, interface)
+ try:
+ class_definition = generatePortalTypeClass(portal_type)
+ except AttributeError:
+ LOG("ERP5Type.Dynamic", WARNING,
+ "Could not access Portal Type Object for type %r"
+ % portal_type, error=sys.exc_info())
+ base_list = (ERP5BaseBroken, )
+ attribute_dict = {}
+ interface_list = []
+ else:
+ base_list, interface_list, attribute_dict = class_definition
+
+
+ # save the old bases to be able to restore a ghost state later
+ if klass.__ghostbase__ is None:
+ # but only do it if we're in the innermost call, otherwise
+ # klass.__bases__ might just be the Document without accessor
+ # holders, and we would override the real ghost class
+ klass.__ghostbase__ = klass.__bases__
+ klass.__bases__ = base_list
+
+ for key, value in attribute_dict.iteritems():
+ setattr(klass, key, value)
+
+ klass.resetAcquisitionAndSecurity()
+ for interface in interface_list:
+ classImplements(klass, interface)
+ finally:
+ ERP5Base.aq_method_lock.release()
def generateLazyPortalTypeClass(portal_type_name):
return PortalTypeMetaClass(portal_type_name, (GhostPortalType,), {})
Modified: erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py?rev=40754&r1=40753&r2=40754&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py [utf8] Fri Nov 26 08:27:37 2010
@@ -33,7 +33,7 @@ from types import ModuleType
from dynamic_module import registerDynamicModule
-from Products.ERP5Type.Base import _aq_reset
+from Products.ERP5Type.Base import _aq_reset, Base
from Products.ERP5Type.Globals import InitializeClass
from Products.ERP5Type.Utils import setDefaultClassProperties
from Products.ERP5Type import document_class_registry, mixin_class_registry
@@ -371,9 +371,13 @@ def synchronizeDynamicModules(context, f
import erp5
- for class_name, klass in inspect.getmembers(erp5.portal_type,
- inspect.isclass):
- klass.restoreGhostState()
+ Base.aq_method_lock.acquire()
+ try:
+ for class_name, klass in inspect.getmembers(erp5.portal_type,
+ inspect.isclass):
+ klass.restoreGhostState()
+ finally:
+ Base.aq_method_lock.release()
# Clear accessor holders of ZODB Property Sheets
for property_sheet_id in erp5.accessor_holder.__dict__.keys():
More information about the Erp5-report
mailing list