Commit d2e183fa authored by Vincent Pelletier's avatar Vincent Pelletier

It is pointless to instantiate a lock as a local value, as function local...

It is pointless to instantiate a lock as a local value, as function local values are local to any given call, hence local to a thread.
Moreover, there is no need to lock access to a persistent object, as its access is protected by ACID.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29082 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 67f8bdca
......@@ -36,8 +36,6 @@ from Products.CMFCore.utils import getToolByName
from zLOG import LOG, WARNING
from Products.ERP5 import _dtmldir
import threading
from BTrees.Length import Length
class IdTool(BaseTool):
......@@ -77,12 +75,7 @@ class IdTool(BaseTool):
if getattr(aq_base(self), 'dict_ids', None) is None:
self.dict_ids = PersistentMapping()
if id_group is not None and id_group!='None':
l = threading.Lock()
l.acquire()
try:
self.dict_ids[id_group] = new_id
finally:
l.release()
security.declareProtected(Permissions.AccessContentsInformation,
'generateNewId')
......@@ -98,9 +91,6 @@ class IdTool(BaseTool):
if id_group is not None and id_group!='None':
# Getting the last id
last_id = None
l = threading.Lock()
l.acquire()
try:
class Dummy:
pass
dummy = Dummy()
......@@ -121,8 +111,6 @@ class IdTool(BaseTool):
# Store the new value
self.dict_ids[id_group] = new_id
finally:
l.release()
return new_id
......
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