Commit fcac8d86 authored by Julien Muchembled's avatar Julien Muchembled

SQLNonContinuousIncreasingIdGenerator: small optimization

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41230 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3924a3bf
......@@ -95,21 +95,20 @@ class SQLNonContinuousIncreasingIdGenerator(IdGenerator):
# If the dictionary not exist, initialize the generator
self.initializeGenerator()
last_max_id_dict = self.last_max_id_dict
if last_max_id_dict.get(id_group, None) is not None and \
last_max_id_dict[id_group].value > new_id:
raise ValueError, 'The last_id %s stored in zodb dictionary is ' \
'higher than the new id %s generated for id_group %s. ' \
'invoke %s/rebuildSqlTable to fix this problem.' % \
(last_max_id_dict[id_group].value, new_id, id_group, self.absolute_url())
# Check the store interval to store the data
store_interval = self.getStoreInterval()
if not store_interval:
store_interval = 1
# Store the new id
if last_max_id_dict.get(id_group, None) is None:
last_max_id = last_max_id_dict.get(id_group)
if last_max_id is None:
last_max_id_dict[id_group] = ScalarMaxConflictResolver(new_id)
elif last_max_id_dict[id_group].value <= (new_id - store_interval):
last_max_id_dict[id_group].set(new_id)
else:
last_max_id_value = last_max_id.value
if new_id <= last_max_id_value:
raise ValueError('The last id %s stored in ZODB dictionary is higher'
' than the new id %s generated for id_group %r.'
' Invoke %s/rebuildSqlTable to fix this problem.'
% (last_max_id_value, new_id, id_group,
self.absolute_url()))
# Check the store interval to store the data
if last_max_id_value <= new_id - (self.getStoreInterval() or 1):
last_max_id.set(new_id)
return new_id
def _updateSqlTable(self):
......
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