Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gabriel Monnerat
erp5
Commits
84451d42
Commit
84451d42
authored
Sep 29, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQLCatalog: Use reserved_uid_lock as modular object instead of class attribute
parent
e46ade7a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
15 deletions
+10
-15
product/ERP5Catalog/tests/testERP5Catalog.py
product/ERP5Catalog/tests/testERP5Catalog.py
+2
-2
product/ZSQLCatalog/SQLCatalog.py
product/ZSQLCatalog/SQLCatalog.py
+8
-13
No files found.
product/ERP5Catalog/tests/testERP5Catalog.py
View file @
84451d42
...
...
@@ -349,14 +349,14 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
portal_catalog
=
self
.
getCatalogTool
()
catalog
=
portal_catalog
.
getSQLCatalog
()
self
.
assertTrue
(
catalog
is
not
None
)
from
Products.ZSQLCatalog.SQLCatalog
import
global_reserved_uid_lock
# Clear out the uid buffer.
#from Products.ZSQLCatalog.SQLCatalog import uid_buffer_dict, get_ident
#uid_buffer_key = get_ident()
#if uid_buffer_key in uid_buffer_dict:
# del uid_buffer_dict[uid_buffer_key]
def
getUIDBuffer
(
*
args
,
**
kw
):
with
catalog
.
__class__
.
_reserved_uid_lock
:
with
global
_reserved_uid_lock
:
return
catalog
.
getUIDBuffer
(
*
args
,
**
kw
)
getUIDBuffer
(
force_new_buffer
=
True
)
...
...
product/ZSQLCatalog/SQLCatalog.py
View file @
84451d42
...
...
@@ -155,6 +155,9 @@ manage_addSQLCatalogForm = DTMLFile('dtml/addSQLCatalog',globals())
# global_uid_buffer_dict[catalog_path][thread_id] = UidBuffer
global_uid_buffer_dict
=
{}
# This is used for exclusive access to the list of reserved uids.
global_reserved_uid_lock
=
allocate_lock
()
def
manage_addSQLCatalog
(
self
,
id
,
title
,
vocab_id
=
'create_default_catalog_'
,
# vocab_id is a strange name - not abbreviation
REQUEST
=
None
):
...
...
@@ -636,8 +639,7 @@ class Catalog(Folder,
# These are class variable on memory, so shared only by threads in the same Zope instance.
# This is set to the time when reserved uids are cleared in this Zope instance.
_local_clear_reserved_time
=
None
# This is used for exclusive access to the list of reserved uids.
_reserved_uid_lock
=
allocate_lock
()
# This is an instance id which specifies who owns which reserved uids.
_instance_id
=
getattr
(
getConfiguration
(),
'instance_id'
,
None
)
...
...
@@ -1204,7 +1206,7 @@ class Catalog(Folder,
security
.
declarePrivate
(
'getUIDBuffer'
)
def
getUIDBuffer
(
self
,
force_new_buffer
=
False
):
klass
=
self
.
__class__
assert
klass
.
_reserved_uid_lock
.
locked
()
assert
global
_reserved_uid_lock
.
locked
()
assert
getattr
(
self
,
'aq_base'
,
None
)
is
not
None
instance_key
=
self
.
getPhysicalPath
()
if
instance_key
not
in
global_uid_buffer_dict
:
...
...
@@ -1225,7 +1227,7 @@ class Catalog(Folder,
Produces reserved uids in advance
"""
klass
=
self
.
__class__
assert
klass
.
_reserved_uid_lock
.
locked
()
assert
global
_reserved_uid_lock
.
locked
()
# This checks if the list of local reserved uids was cleared after clearReserved
# had been called.
force_new_buffer
=
(
klass
.
_local_clear_reserved_time
!=
self
.
_last_clear_reserved_time
)
...
...
@@ -1317,8 +1319,7 @@ class Catalog(Folder,
return
None
klass
=
self
.
__class__
try
:
klass
.
_reserved_uid_lock
.
acquire
()
with
global_reserved_uid_lock
:
self
.
produceUid
()
uid_buffer
=
self
.
getUIDBuffer
()
if
len
(
uid_buffer
)
>
0
:
...
...
@@ -1330,8 +1331,6 @@ class Catalog(Folder,
return
long
(
uid
)
else
:
raise
CatalogError
(
"Could not retrieve new uid"
)
finally
:
klass
.
_reserved_uid_lock
.
release
()
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogObject'
)
def
manage_catalogObject
(
self
,
REQUEST
,
RESPONSE
,
URL1
,
urls
=
None
):
...
...
@@ -1564,9 +1563,7 @@ class Catalog(Folder,
#LOG('catalogObject', 0, 'uid = %r, catalog_path = %r' % (uid, catalog_path))
if
catalog_path
==
"reserved"
:
# Reserved line in catalog table
lock
=
self
.
__class__
.
_reserved_uid_lock
try
:
lock
.
acquire
()
with
global_reserved_uid_lock
:
uid_buffer
=
self
.
getUIDBuffer
()
if
uid_buffer
is
not
None
:
# This is the case where:
...
...
@@ -1581,8 +1578,6 @@ class Catalog(Folder,
uid_buffer
.
remove
(
uid
)
except
ValueError
:
pass
finally
:
lock
.
release
()
elif
catalog_path
==
'deleted'
:
# Two possible cases:
# - Reindexed object's path changed (ie, it or at least one of its
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment