Commit 80cb6657 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Cosmetic: Use ImportLock() rather than aq_method_lock (a29456bc).

It is exactly the same at the end but the name of the latter does not make
sense in this context. Moreover, it allows to get rid of Base import.
parent c90881cc
...@@ -34,7 +34,6 @@ import sys ...@@ -34,7 +34,6 @@ import sys
import threading import threading
from Products.ERP5.ERP5Site import getSite from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.Base import Base
from types import ModuleType from types import ModuleType
from zLOG import LOG, INFO, BLATHER from zLOG import LOG, INFO, BLATHER
...@@ -44,6 +43,8 @@ class ComponentVersionPackage(ModuleType): ...@@ -44,6 +43,8 @@ class ComponentVersionPackage(ModuleType):
""" """
__path__ = [] __path__ = []
from Products.ERP5Type.dynamic.import_lock import ImportLock
class ComponentDynamicPackage(ModuleType): class ComponentDynamicPackage(ModuleType):
""" """
A top-level component is a package as it contains modules, this is required A top-level component is a package as it contains modules, this is required
...@@ -65,6 +66,7 @@ class ComponentDynamicPackage(ModuleType): ...@@ -65,6 +66,7 @@ class ComponentDynamicPackage(ModuleType):
# Necessary otherwise imports will fail because an object is considered a # Necessary otherwise imports will fail because an object is considered a
# package only if __path__ is defined # package only if __path__ is defined
__path__ = [] __path__ = []
__lock = ImportLock()
def __init__(self, namespace, portal_type): def __init__(self, namespace, portal_type):
super(ComponentDynamicPackage, self).__init__(namespace) super(ComponentDynamicPackage, self).__init__(namespace)
...@@ -105,7 +107,7 @@ class ComponentDynamicPackage(ModuleType): ...@@ -105,7 +107,7 @@ class ComponentDynamicPackage(ModuleType):
# objectValues should not be used for a large number of objects, but # objectValues should not be used for a large number of objects, but
# this is only done upon reset, moreover using the Catalog is too risky # this is only done upon reset, moreover using the Catalog is too risky
# as it lags behind and depends upon objects being reindexed # as it lags behind and depends upon objects being reindexed
with Base.aq_method_lock: with self.__lock:
for component in component_tool.objectValues(portal_type=self._portal_type): for component in component_tool.objectValues(portal_type=self._portal_type):
# Only consider modified or validated states as state transition will # Only consider modified or validated states as state transition will
# be handled by component_validation_workflow which will take care of # be handled by component_validation_workflow which will take care of
...@@ -308,7 +310,7 @@ class ComponentDynamicPackage(ModuleType): ...@@ -308,7 +310,7 @@ class ComponentDynamicPackage(ModuleType):
Make sure that loading module is thread-safe using aq_method_lock to make Make sure that loading module is thread-safe using aq_method_lock to make
sure that modules do not disappear because of an ongoing reset sure that modules do not disappear because of an ongoing reset
""" """
with Base.aq_method_lock: with self.__lock:
return self.__load_module(fullname) return self.__load_module(fullname)
def reset(self, sub_package=None): def reset(self, sub_package=None):
......
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