diff --git a/product/ERP5Catalog/CatalogTool.py b/product/ERP5Catalog/CatalogTool.py index 3567e4537104835c91ae6b8359c5ecf0b042bb9f..67db02ce8f6734566777eed695bea74638e50218 100644 --- a/product/ERP5Catalog/CatalogTool.py +++ b/product/ERP5Catalog/CatalogTool.py @@ -369,7 +369,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): if id is None: # Check if we want to use an archive #if getattr(aq_base(self.portal_preferences), 'uid', None) is not None: - archive_path = self.portal_preferences.getPreferredArchive(sql_catalog_id=self.default_sql_catalog_id) + archive_path = self.portal_preferences.getPreferredArchive(sql_catalog_id=self.getDefaultSqlCatalogId()) if archive_path not in ('', None): try: archive = self.restrictedTraverse(archive_path) diff --git a/product/ERP5Catalog/Tool/ArchiveTool.py b/product/ERP5Catalog/Tool/ArchiveTool.py index 49c93d6c70c549b0c0c7d13698bf6a198f198b01..46cbb83075a830e542b02308868f468528b4990c 100644 --- a/product/ERP5Catalog/Tool/ArchiveTool.py +++ b/product/ERP5Catalog/Tool/ArchiveTool.py @@ -78,7 +78,7 @@ class ArchiveTool(BaseTool): """ Return the archive used for the current catalog """ - current_catalog = self.portal_catalog.default_sql_catalog_id + current_catalog = self.portal_catalog.getDefaultSqlCatalogId() current_archive_list = [x.getObject() for x in self.searchFolder(validation_state="validated") \ if x.getCatalogId() == current_catalog] if len(current_archive_list) == 0: diff --git a/product/ERP5Catalog/tests/testERP5Catalog.py b/product/ERP5Catalog/tests/testERP5Catalog.py index 8be3312c5c2877366be84efb3f951336807f3347..a886e3377f5923ad13598b5eb57126d6e1e8d378 100644 --- a/product/ERP5Catalog/tests/testERP5Catalog.py +++ b/product/ERP5Catalog/tests/testERP5Catalog.py @@ -115,7 +115,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): def beforeTearDown(self): # restore default_catalog - self.portal.portal_catalog.default_sql_catalog_id = 'erp5_mysql_innodb' + self.portal.portal_catalog._setDefaultSqlCatalogId('erp5_mysql_innodb') self.portal.portal_catalog.hot_reindexing_state = None # clear Modules for module in [ self.getPersonModule(), diff --git a/product/ZSQLCatalog/ZSQLCatalog.py b/product/ZSQLCatalog/ZSQLCatalog.py index 105d6994d3d70554da9006989f4808637fae7149..e59540a76c265785e8992bd4b3543ccf70d00303 100644 --- a/product/ZSQLCatalog/ZSQLCatalog.py +++ b/product/ZSQLCatalog/ZSQLCatalog.py @@ -197,19 +197,26 @@ class ZCatalog(Folder, Persistent, Implicit): def getSQLCatalogIdList(self): return self.objectIds(spec=('SQLCatalog',)) + def getDefaultSqlCatalogId(self): + return self.default_sql_catalog_id + + def _setDefaultSqlCatalogId(self, value): + if value: + self.default_sql_catalog_id = value + security.declarePublic('getSQLCatalog') def getSQLCatalog(self, id=None, default_value=None): """ Get the default SQL Catalog. """ if id is None: - if not self.default_sql_catalog_id: + if not self.getDefaultSqlCatalogId(): id_list = self.getSQLCatalogIdList() if len(id_list) > 0: - self.default_sql_catalog_id = id_list[0] + self._setDefaultSqlCatalogId(id_list[0]) else: return default_value - id = self.default_sql_catalog_id + id = self.getDefaultSqlCatalogId() return self._getOb(id, default_value) @@ -256,7 +263,7 @@ class ZCatalog(Folder, Persistent, Implicit): """ #LOG("_setHotReindexingState call", 300, state) if source_sql_catalog_id is None: - source_sql_catalog_id = self.default_sql_catalog_id + source_sql_catalog_id = self.getDefaultSqlCatalogId() if state == HOT_REINDEXING_FINISHED_STATE: self.hot_reindexing_state = None @@ -283,7 +290,7 @@ class ZCatalog(Folder, Persistent, Implicit): current_archive = self.portal_archives.getCurrentArchive() else: current_archive = None - default_catalog_id = self.default_sql_catalog_id + default_catalog_id = self.getDefaultSqlCatalogId() self._exchangeDatabases(source_sql_catalog_id=source_sql_catalog_id, destination_sql_catalog_id=destination_sql_catalog_id, skin_selection_dict=skin_selection_dict, @@ -381,8 +388,8 @@ class ZCatalog(Folder, Persistent, Implicit): """ Exchange two databases. """ - if self.default_sql_catalog_id == source_sql_catalog_id: - self.default_sql_catalog_id = destination_sql_catalog_id + if self.getDefaultSqlCatalogId() == source_sql_catalog_id: + self._setDefaultSqlCatalogId(destination_sql_catalog_id) id_tool = getattr(self.getPortalObject(), 'portal_ids', None) if id_tool is None: # Insert the latest generated uid. @@ -453,7 +460,7 @@ class ZCatalog(Folder, Persistent, Implicit): ' you want to do is a "clear catalog" and an '\ '"ERP5Site_reindexAll".' - if source_sql_catalog_id != self.default_sql_catalog_id: + if source_sql_catalog_id != self.getDefaultSqlCatalogId(): LOG('ZSQLCatalog', 0, 'Warning : Hot reindexing is started with a '\ 'source catalog which is not the default one.')