Commit 723c63d0 authored by Aurel's avatar Aurel

store path on tool instead of object for archiving

add more comment for archiving
fix some test condition which were making catalogObjectList
relaunching activity for destination catalog insteat of calogging in
it directly


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17359 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent df9359d0
...@@ -184,7 +184,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -184,7 +184,7 @@ class ZCatalog(Folder, Persistent, Implicit):
destination_sql_catalog_id = None destination_sql_catalog_id = None
hot_reindexing_state = None hot_reindexing_state = None
default_sql_catalog_id = None default_sql_catalog_id = None
archive = None archive_path = None
manage_catalogAddRowForm = DTMLFile('dtml/catalogAddRowForm', globals()) manage_catalogAddRowForm = DTMLFile('dtml/catalogAddRowForm', globals())
manage_catalogFilter = DTMLFile( 'dtml/catalogFilter', globals() ) manage_catalogFilter = DTMLFile( 'dtml/catalogFilter', globals() )
...@@ -252,7 +252,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -252,7 +252,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return HOT_REINDEXING_FINISHED_STATE return HOT_REINDEXING_FINISHED_STATE
return value return value
def setHotReindexingState(self, state='', source_sql_catalog_id=None, destination_sql_catalog_id=None, archive=None): def setHotReindexingState(self, state='', source_sql_catalog_id=None, destination_sql_catalog_id=None, archive_path=None):
""" """
Set the state of hot reindexing. Set the state of hot reindexing.
...@@ -267,13 +267,13 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -267,13 +267,13 @@ class ZCatalog(Folder, Persistent, Implicit):
self.hot_reindexing_state = None self.hot_reindexing_state = None
self.source_sql_catalog_id = None self.source_sql_catalog_id = None
self.destination_sql_catalog_id = None self.destination_sql_catalog_id = None
self.archive = None self.archive_path = None
elif state == HOT_REINDEXING_RECORDING_STATE or \ elif state == HOT_REINDEXING_RECORDING_STATE or \
state == HOT_REINDEXING_DOUBLE_INDEXING_STATE: state == HOT_REINDEXING_DOUBLE_INDEXING_STATE:
self.hot_reindexing_state = state self.hot_reindexing_state = state
self.source_sql_catalog_id = source_sql_catalog_id self.source_sql_catalog_id = source_sql_catalog_id
self.destination_sql_catalog_id = destination_sql_catalog_id self.destination_sql_catalog_id = destination_sql_catalog_id
self.archive = archive self.archive_path = archive_path
else: else:
raise CatalogError, 'unknown hot reindexing state %s' % state raise CatalogError, 'unknown hot reindexing state %s' % state
...@@ -399,7 +399,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -399,7 +399,7 @@ class ZCatalog(Folder, Persistent, Implicit):
def manage_hotReindexAll(self, source_sql_catalog_id, def manage_hotReindexAll(self, source_sql_catalog_id,
destination_sql_catalog_id, destination_sql_catalog_id,
archive=None, archive_path=None,
source_sql_connection_id_list=None, source_sql_connection_id_list=None,
destination_sql_connection_id_list=None, destination_sql_connection_id_list=None,
skin_name_list=None, skin_name_list=None,
...@@ -495,7 +495,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -495,7 +495,7 @@ class ZCatalog(Folder, Persistent, Implicit):
self.setHotReindexingState(HOT_REINDEXING_RECORDING_STATE, self.setHotReindexingState(HOT_REINDEXING_RECORDING_STATE,
source_sql_catalog_id=source_sql_catalog_id, source_sql_catalog_id=source_sql_catalog_id,
destination_sql_catalog_id=destination_sql_catalog_id, destination_sql_catalog_id=destination_sql_catalog_id,
archive=archive) archive_path=archive_path)
# Clear the future catalog and start reindexing the site in it. # Clear the future catalog and start reindexing the site in it.
final_activity_tag = 'hot_reindex_last_ERP5Site_reindexAll_tag' final_activity_tag = 'hot_reindex_last_ERP5Site_reindexAll_tag'
self.ERP5Site_reindexAll(sql_catalog_id=destination_sql_catalog_id, self.ERP5Site_reindexAll(sql_catalog_id=destination_sql_catalog_id,
...@@ -694,7 +694,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -694,7 +694,7 @@ class ZCatalog(Folder, Persistent, Implicit):
hot_reindexing = (self.hot_reindexing_state is not None) and \ hot_reindexing = (self.hot_reindexing_state is not None) and \
(catalog is not None) and \ (catalog is not None) and \
(self.source_sql_catalog_id == catalog.id) (self.source_sql_catalog_id == catalog.id)
archiving = self.archive is not None archiving = self.archive_path is not None
wrapped_object_list = [] wrapped_object_list = []
failed_object_list = [] failed_object_list = []
url_list = [] url_list = []
...@@ -707,7 +707,10 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -707,7 +707,10 @@ class ZCatalog(Folder, Persistent, Implicit):
# Create archive obj list if necessary # Create archive obj list if necessary
if archiving: if archiving:
archive_obj_list = [self.archive,] # while archiving only test with the archive we used, do not care
# of other as they must alredy be ok
archive = self.unrestrictedTraverse(self.archive_path)
archive_obj_list = [archive,]
for archive_path in archive_list: for archive_path in archive_list:
try: try:
archive = self.unrestrictedTraverse(archive_path) archive = self.unrestrictedTraverse(archive_path)
...@@ -716,6 +719,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -716,6 +719,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if archive.getCatalogId() == self.destination_sql_catalog_id: if archive.getCatalogId() == self.destination_sql_catalog_id:
archive_obj_list.append(archive) archive_obj_list.append(archive)
else: else:
# otherwise take all archive in use to knwo where object must go
archive_obj_list = [] archive_obj_list = []
for archive_path in archive_list: for archive_path in archive_list:
try: try:
...@@ -723,7 +727,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -723,7 +727,7 @@ class ZCatalog(Folder, Persistent, Implicit):
except KeyError: except KeyError:
continue continue
archive_obj_list.append(archive) archive_obj_list.append(archive)
# Construct list of object to catalog # Construct list of object to catalogged
for obj in object_list: for obj in object_list:
if hot_reindexing: if hot_reindexing:
try: try:
...@@ -740,7 +744,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -740,7 +744,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if (not disable_archive) and (archiving or (len(archive_obj_list) > 0 and \ if (not disable_archive) and (archiving or (len(archive_obj_list) > 0 and \
(sql_catalog_id == default_catalog.id or \ (sql_catalog_id == default_catalog.id or \
sql_catalog_id is None))): sql_catalog_id is None))):
# check in which archive object must go # check in which archive object must go if we defined archive
catalog_id = None catalog_id = None
for archive in archive_obj_list: for archive in archive_obj_list:
if archive.test(obj) is True: if archive.test(obj) is True:
...@@ -751,11 +755,12 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -751,11 +755,12 @@ class ZCatalog(Folder, Persistent, Implicit):
catalog_dict[catalog_id]['obj'].append(obj) catalog_dict[catalog_id]['obj'].append(obj)
else: else:
catalog_dict[catalog_id] = {'priority' : priority, 'obj' : [obj,]} catalog_dict[catalog_id] = {'priority' : priority, 'obj' : [obj,]}
if catalog_id is None: # or sql_catalog_id is None: if catalog_id is None or sql_catalog_id is None or self.source_sql_catalog_id == catalog.id:
# at least put object in current catalog if no archive match # at least put object in current catalog if no archive match
goto_current_catalog = 1 goto_current_catalog = 1
else: else:
goto_current_catalog = 1 goto_current_catalog = 1
if goto_current_catalog: if goto_current_catalog:
try: try:
# wrap object only when sure it will be reindex now # wrap object only when sure it will be reindex now
...@@ -771,8 +776,13 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -771,8 +776,13 @@ class ZCatalog(Folder, Persistent, Implicit):
# run activity or execute for each archive depending on priority # run activity or execute for each archive depending on priority
if len(catalog_dict): if len(catalog_dict):
for catalog_id in catalog_dict.keys(): for catalog_id in catalog_dict.keys():
if goto_current_catalog and catalog_id == default_catalog.id:
# if we reindex in current catalog, do not relaunch an activity for this
continue
d = catalog_dict[catalog_id] d = catalog_dict[catalog_id]
if hot_reindexing and self.hot_reindexing_state == HOT_REINDEXING_DOUBLE_INDEXING_STATE and \ # hot_reindexing is True when creating an object during a hot reindex, in this case, we don't want
# to reindex it in destination catalog, it will be recorded an play only once
if not hot_reindexing and self.hot_reindexing_state != HOT_REINDEXING_DOUBLE_INDEXING_STATE and \
self.destination_sql_catalog_id == catalog_id: self.destination_sql_catalog_id == catalog_id:
destination_catalog = self.getSQLCatalog(self.destination_sql_catalog_id) destination_catalog = self.getSQLCatalog(self.destination_sql_catalog_id)
# wrap all objects # wrap all objects
...@@ -790,7 +800,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -790,7 +800,7 @@ class ZCatalog(Folder, Persistent, Implicit):
destination_catalog.catalogObjectList(wrapped_object_list_2, **kw) destination_catalog.catalogObjectList(wrapped_object_list_2, **kw)
else: else:
for obj in d['obj']: for obj in d['obj']:
obj.reindexObject(sql_catalog_id=catalog_id, activate_kw = \ obj._reindexObject(sql_catalog_id=catalog_id, activate_kw = \
{'priority': d['priority']}, disable_archive=1, **kw) {'priority': d['priority']}, disable_archive=1, **kw)
if catalog is not None: if catalog is not None:
......
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