Change the methods for the new API of id tool


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34553 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 35c825a5
...@@ -82,8 +82,10 @@ class SQLDict(RAMDict, SQLBase): ...@@ -82,8 +82,10 @@ class SQLDict(RAMDict, SQLBase):
tag_list = [message.activity_kw.get('tag', '') for message in registered_message_list] tag_list = [message.activity_kw.get('tag', '') for message in registered_message_list]
serialization_tag_list = [message.activity_kw.get('serialization_tag', '') for message in registered_message_list] serialization_tag_list = [message.activity_kw.get('serialization_tag', '') for message in registered_message_list]
order_validation_text_list = [self.getOrderValidationText(message) for message in registered_message_list] order_validation_text_list = [self.getOrderValidationText(message) for message in registered_message_list]
uid_list = activity_tool.getPortalObject().portal_ids.generateNewLengthIdList(id_group='portal_activity', # The uid_list also is store in the ZODB
id_count=len(registered_message_list), store=0) uid_list = activity_tool.getPortalObject().portal_ids.\
generateNewIdList(id_generator='uid', id_group='portal_activity',
id_count=len(registered_message_list))
activity_tool.SQLDict_writeMessageList( uid_list = uid_list, activity_tool.SQLDict_writeMessageList( uid_list = uid_list,
path_list = path_list, path_list = path_list,
active_process_uid_list=active_process_uid_list, active_process_uid_list=active_process_uid_list,
......
...@@ -78,9 +78,10 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -78,9 +78,10 @@ class SQLQueue(RAMQueue, SQLBase):
message_list = [m for m in message_list if m.is_registered] message_list = [m for m in message_list if m.is_registered]
for i in xrange(0, len(message_list), MAX_MESSAGE_LIST_SIZE): for i in xrange(0, len(message_list), MAX_MESSAGE_LIST_SIZE):
registered_message_list = message_list[i:i + MAX_MESSAGE_LIST_SIZE] registered_message_list = message_list[i:i + MAX_MESSAGE_LIST_SIZE]
uid_list = activity_tool.getPortalObject().portal_ids.generateNewLengthIdList( # The uid_list also is store in the ZODB
id_group='portal_activity_queue', id_count=len(registered_message_list), uid_list = activity_tool.getPortalObject().portal_ids.generateNewIdList(
store=0) id_generator='uid', id_group='portal_activity_queue',
id_count=len(registered_message_list))
path_list = ['/'.join(m.object_path) for m in registered_message_list] path_list = ['/'.join(m.object_path) for m in registered_message_list]
active_process_uid_list = [m.active_process_uid for m in registered_message_list] active_process_uid_list = [m.active_process_uid for m in registered_message_list]
method_id_list = [m.method_id for m in registered_message_list] method_id_list = [m.method_id for m in registered_message_list]
......
...@@ -643,23 +643,6 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -643,23 +643,6 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
__call__ = searchResults __call__ = searchResults
security.declarePrivate('beforeCatalogClear')
def beforeCatalogClear(self):
"""
Clears the catalog by calling a list of methods
"""
id_tool = self.getPortalObject().portal_ids
try:
id_tool.dumpDictLengthIdsItems()
except ConflictError:
raise
except:
# Swallow exceptions to allow catalog clear to happen.
# For example, is portal_ids table does not exist and exception will
# be thrown by portal_id methods.
LOG('ERP5Catalog.beforeCatalogClear', WARNING,
'beforeCatalogClear failed', error=sys.exc_info())
security.declarePrivate('unrestrictedSearchResults') security.declarePrivate('unrestrictedSearchResults')
def unrestrictedSearchResults(self, REQUEST=None, **kw): def unrestrictedSearchResults(self, REQUEST=None, **kw):
"""Calls ZSQLCatalog.searchResults directly without restrictions. """Calls ZSQLCatalog.searchResults directly without restrictions.
......
...@@ -1973,7 +1973,6 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1973,7 +1973,6 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
self.assertTrue("TRUNCATE(catalog.uid,2) = '2567.54'" in sql_src or \ self.assertTrue("TRUNCATE(catalog.uid,2) = '2567.54'" in sql_src or \
'TRUNCATE(`catalog`.`uid`, 2) = 2567.54' in sql_src, sql_src) 'TRUNCATE(`catalog`.`uid`, 2) = 2567.54' in sql_src, sql_src)
@skip('Regression portal_ids must be delete of catalog')
def test_56_CreateUidDuringClearCatalog(self, quiet=quiet,run=run_all_test): def test_56_CreateUidDuringClearCatalog(self, quiet=quiet,run=run_all_test):
""" """
Create a script in the catalog to generate a uid list Create a script in the catalog to generate a uid list
...@@ -1982,7 +1981,8 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1982,7 +1981,8 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
# Add a script to create uid list # Add a script to create uid list
catalog = self.getCatalogTool().getSQLCatalog() catalog = self.getCatalogTool().getSQLCatalog()
script_id = 'z0_zCreateUid' script_id = 'z0_zCreateUid'
script_content = "context.getPortalObject().portal_ids.generateNewLengthIdList(id_group='text_uid')" script_content = "context.getPortalObject().portal_ids.generateNewIdList(id_generator='uid',\
id_group='text_uid')"
script = createZODBPythonScript(catalog, script_id, script = createZODBPythonScript(catalog, script_id,
'*args,**kw', script_content) '*args,**kw', script_content)
sql_clear_catalog = list(catalog.sql_clear_catalog) sql_clear_catalog = list(catalog.sql_clear_catalog)
......
...@@ -254,9 +254,8 @@ class FolderMixIn(ExtensionClass.Base): ...@@ -254,9 +254,8 @@ class FolderMixIn(ExtensionClass.Base):
while self.hasContent(my_id): while self.hasContent(my_id):
my_id = idGenerator() my_id = idGenerator()
else: else:
my_id = str(self.portal_ids.generateNewId( id_group=id_group, my_id = str(self.portal_ids.generateNewId(id_generator='document',
default=default, id_group=id_group, default=default, method=method ))
method=method ))
return my_id return my_id
security.declareProtected(Permissions.View, 'hasContent') security.declareProtected(Permissions.View, 'hasContent')
......
...@@ -774,8 +774,8 @@ class Catalog(Folder, ...@@ -774,8 +774,8 @@ class Catalog(Folder,
default = previous_security_uid() + 1 default = previous_security_uid() + 1
else: else:
default = previous_security_uid default = previous_security_uid
security_uid = id_tool.generateNewLengthId(id_group='security_uid_index', security_uid = int(id_tool.generateNewId(id_generator='uid',
default=default) id_group='security_uid_index', default=default))
else: else:
previous_security_uid = getattr(self, 'security_uid_index', None) previous_security_uid = getattr(self, 'security_uid_index', None)
if previous_security_uid is None: if previous_security_uid is None:
...@@ -1052,7 +1052,7 @@ class Catalog(Folder, ...@@ -1052,7 +1052,7 @@ class Catalog(Folder,
if id_tool is not None: if id_tool is not None:
if self._max_uid is None: if self._max_uid is None:
self._max_uid = Length(1) self._max_uid = Length(1)
uid_list = id_tool.generateNewLengthIdList(id_group='catalog_uid', uid_list = id_tool.generateNewIdList(id_generator='uid', id_group='catalog_uid',
id_count=UID_BUFFER_SIZE, default=self._max_uid()) id_count=UID_BUFFER_SIZE, default=self._max_uid())
# TODO: if this method is kept and former uid allocation code is # TODO: if this method is kept and former uid allocation code is
# discarded, self._max_uid duplicates work done by portal_ids: it # discarded, self._max_uid duplicates work done by portal_ids: it
......
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