Commit 7d73f8ba authored by Yoshinori Okuji's avatar Yoshinori Okuji

sql_catalog_reserve_uid must be obtained from the catalog instead of the uid buffer.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4457 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2981441b
...@@ -84,7 +84,7 @@ def manage_addSQLCatalog(self, id, title, ...@@ -84,7 +84,7 @@ def manage_addSQLCatalog(self, id, title,
class UidBuffer(TM): class UidBuffer(TM):
"""Uid Buffer class caches a list of reserved uids in a transaction-safe way.""" """Uid Buffer class caches a list of reserved uids in a transaction-safe way."""
def __init__(self): def __init__(self, catalog):
"""Initialize some variables. """Initialize some variables.
temporary_buffer is used to hold reserved uids created by non-committed transactions. temporary_buffer is used to hold reserved uids created by non-committed transactions.
...@@ -101,6 +101,7 @@ class UidBuffer(TM): ...@@ -101,6 +101,7 @@ class UidBuffer(TM):
self.temporary_buffer = {} self.temporary_buffer = {}
self.finished_buffer = [] self.finished_buffer = []
self.allocated_buffer = {} self.allocated_buffer = {}
self.catalog = catalog
def _begin(self, *ignored): def _begin(self, *ignored):
# In Zope 2.8 (ZODB 3.4), use beforeCommitHook instead of # In Zope 2.8 (ZODB 3.4), use beforeCommitHook instead of
...@@ -116,8 +117,8 @@ class UidBuffer(TM): ...@@ -116,8 +117,8 @@ class UidBuffer(TM):
tid = get_ident() tid = get_ident()
try: try:
uid_list = self.allocated_buffer[tid] uid_list = self.allocated_buffer[tid]
method_id = self.sql_catalog_reserve_uid method_id = self.catalog.sql_catalog_reserve_uid
method = getattr(self, method_id) method = getattr(self.catalog, method_id)
method(uid = uid_list) method(uid = uid_list)
del self.allocated_buffer[tid] del self.allocated_buffer[tid]
except KeyError: except KeyError:
...@@ -826,10 +827,10 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -826,10 +827,10 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
# This checks if the list of local reserved uids was cleared after clearReserved # This checks if the list of local reserved uids was cleared after clearReserved
# had been called. # had been called.
if klass._local_clear_reserved_time != self._last_clear_reserved_time: if klass._local_clear_reserved_time != self._last_clear_reserved_time:
self._v_uid_buffer = UidBuffer() self._v_uid_buffer = UidBuffer(self)
klass._local_clear_reserved_time = self._last_clear_reserved_time klass._local_clear_reserved_time = self._last_clear_reserved_time
elif not hasattr(self, '_v_uid_buffer'): elif not hasattr(self, '_v_uid_buffer'):
self._v_uid_buffer = UidBuffer() self._v_uid_buffer = UidBuffer(self)
if len(self._v_uid_buffer) == 0: if len(self._v_uid_buffer) == 0:
method_id = self.sql_catalog_produce_reserved method_id = self.sql_catalog_produce_reserved
method = getattr(self, method_id) method = getattr(self, method_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