Commit 87aba4ec authored by Nicolas Dumazet's avatar Nicolas Dumazet

use lock to avoid reloading portal type classes in one thread while

the other one loads them


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40754 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c89481d7
...@@ -159,7 +159,9 @@ class PortalTypeMetaClass(ExtensionClass): ...@@ -159,7 +159,9 @@ class PortalTypeMetaClass(ExtensionClass):
raise AttributeError("Could not find a portal type class in" raise AttributeError("Could not find a portal type class in"
" class hierarchy") " class hierarchy")
ERP5Base.aq_method_lock.acquire()
portal_type = klass.__name__ portal_type = klass.__name__
try:
try: try:
class_definition = generatePortalTypeClass(portal_type) class_definition = generatePortalTypeClass(portal_type)
except AttributeError: except AttributeError:
...@@ -187,6 +189,8 @@ class PortalTypeMetaClass(ExtensionClass): ...@@ -187,6 +189,8 @@ class PortalTypeMetaClass(ExtensionClass):
klass.resetAcquisitionAndSecurity() klass.resetAcquisitionAndSecurity()
for interface in interface_list: for interface in interface_list:
classImplements(klass, interface) classImplements(klass, interface)
finally:
ERP5Base.aq_method_lock.release()
def generateLazyPortalTypeClass(portal_type_name): def generateLazyPortalTypeClass(portal_type_name):
return PortalTypeMetaClass(portal_type_name, (GhostPortalType,), {}) return PortalTypeMetaClass(portal_type_name, (GhostPortalType,), {})
...@@ -33,7 +33,7 @@ from types import ModuleType ...@@ -33,7 +33,7 @@ from types import ModuleType
from dynamic_module import registerDynamicModule 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.Globals import InitializeClass
from Products.ERP5Type.Utils import setDefaultClassProperties from Products.ERP5Type.Utils import setDefaultClassProperties
from Products.ERP5Type import document_class_registry, mixin_class_registry from Products.ERP5Type import document_class_registry, mixin_class_registry
...@@ -371,9 +371,13 @@ def synchronizeDynamicModules(context, force=False): ...@@ -371,9 +371,13 @@ def synchronizeDynamicModules(context, force=False):
import erp5 import erp5
Base.aq_method_lock.acquire()
try:
for class_name, klass in inspect.getmembers(erp5.portal_type, for class_name, klass in inspect.getmembers(erp5.portal_type,
inspect.isclass): inspect.isclass):
klass.restoreGhostState() klass.restoreGhostState()
finally:
Base.aq_method_lock.release()
# Clear accessor holders of ZODB Property Sheets # Clear accessor holders of ZODB Property Sheets
for property_sheet_id in erp5.accessor_holder.__dict__.keys(): for property_sheet_id in erp5.accessor_holder.__dict__.keys():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment