diff --git a/product/ERP5/bootstrap/erp5_core/PropertySheetTemplateItem/portal_property_sheets/CatalogTool/default_sql_catalog_id_property.xml b/product/ERP5/bootstrap/erp5_core/PropertySheetTemplateItem/portal_property_sheets/CatalogTool/default_sql_catalog_id_property.xml deleted file mode 100644 index ec314ef1502880b9be50dd37c9260324a772a936..0000000000000000000000000000000000000000 --- a/product/ERP5/bootstrap/erp5_core/PropertySheetTemplateItem/portal_property_sheets/CatalogTool/default_sql_catalog_id_property.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0"?> -<ZopeData> - <record id="1" aka="AAAAAAAAAAE="> - <pickle> - <global name="Standard Property" module="erp5.portal_type"/> - </pickle> - <pickle> - <dictionary> - <item> - <key> <string>_local_properties</string> </key> - <value> - <tuple> - <dictionary> - <item> - <key> <string>id</string> </key> - <value> <string>select_variable</string> </value> - </item> - <item> - <key> <string>type</string> </key> - <value> <string>string</string> </value> - </item> - </dictionary> - <dictionary> - <item> - <key> <string>id</string> </key> - <value> <string>mode</string> </value> - </item> - <item> - <key> <string>type</string> </key> - <value> <string>string</string> </value> - </item> - </dictionary> - </tuple> - </value> - </item> - <item> - <key> <string>categories</string> </key> - <value> - <tuple> - <string>elementary_type/string</string> - </tuple> - </value> - </item> - <item> - <key> <string>description</string> </key> - <value> <string>The id of the default SQL Catalog</string> </value> - </item> - <item> - <key> <string>id</string> </key> - <value> <string>default_sql_catalog_id_property</string> </value> - </item> - <item> - <key> <string>mode</string> </key> - <value> <string>w</string> </value> - </item> - <item> - <key> <string>portal_type</string> </key> - <value> <string>Standard Property</string> </value> - </item> - <item> - <key> <string>select_variable</string> </key> - <value> <string>getSQLCatalogIdList</string> </value> - </item> - </dictionary> - </pickle> - </record> -</ZopeData> diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_viewCatalogList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_viewCatalogList.xml index f82006311990e6edbb453fa1caf03c8a4f235bb8..ced7b7addfe5a2ddebc76542e94fb361d1219ec1 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_viewCatalogList.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_viewCatalogList.xml @@ -86,7 +86,6 @@ <key> <string>right</string> </key> <value> <list> - <string>my_default_sql_catalog_id</string> <string>my_default_erp5_catalog_id</string> </list> </value> diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_viewCatalogList/my_default_sql_catalog_id.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_viewCatalogList/my_default_sql_catalog_id.xml deleted file mode 100644 index f8e4c2cc2f366d76cf9f54f2fe5037887a1d0557..0000000000000000000000000000000000000000 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_viewCatalogList/my_default_sql_catalog_id.xml +++ /dev/null @@ -1,272 +0,0 @@ -<?xml version="1.0"?> -<ZopeData> - <record id="1" aka="AAAAAAAAAAE="> - <pickle> - <global name="StringField" module="Products.Formulator.StandardFields"/> - </pickle> - <pickle> - <dictionary> - <item> - <key> <string>id</string> </key> - <value> <string>my_default_sql_catalog_id</string> </value> - </item> - <item> - <key> <string>message_values</string> </key> - <value> - <dictionary> - <item> - <key> <string>external_validator_failed</string> </key> - <value> <string>The input failed the external validator.</string> </value> - </item> - <item> - <key> <string>required_not_found</string> </key> - <value> <string>Input is required but no input given.</string> </value> - </item> - <item> - <key> <string>too_long</string> </key> - <value> <string>Too much input was given.</string> </value> - </item> - </dictionary> - </value> - </item> - <item> - <key> <string>overrides</string> </key> - <value> - <dictionary> - <item> - <key> <string>alternate_name</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>css_class</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>default</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>description</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>display_maxwidth</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>display_width</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>editable</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>enabled</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>external_validator</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>extra</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>hidden</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>input_type</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>max_length</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>required</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>title</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>truncate</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>unicode</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>whitespace_preserve</string> </key> - <value> <string></string> </value> - </item> - </dictionary> - </value> - </item> - <item> - <key> <string>tales</string> </key> - <value> - <dictionary> - <item> - <key> <string>alternate_name</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>css_class</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>default</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>description</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>display_maxwidth</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>display_width</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>editable</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>enabled</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>external_validator</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>extra</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>hidden</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>input_type</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>max_length</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>required</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>title</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>truncate</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>unicode</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>whitespace_preserve</string> </key> - <value> <string></string> </value> - </item> - </dictionary> - </value> - </item> - <item> - <key> <string>values</string> </key> - <value> - <dictionary> - <item> - <key> <string>alternate_name</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>css_class</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>default</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>description</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>display_maxwidth</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>display_width</string> </key> - <value> <int>20</int> </value> - </item> - <item> - <key> <string>editable</string> </key> - <value> <int>0</int> </value> - </item> - <item> - <key> <string>enabled</string> </key> - <value> <int>1</int> </value> - </item> - <item> - <key> <string>external_validator</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>extra</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>hidden</string> </key> - <value> <int>0</int> </value> - </item> - <item> - <key> <string>input_type</string> </key> - <value> <string>text</string> </value> - </item> - <item> - <key> <string>max_length</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>required</string> </key> - <value> <int>0</int> </value> - </item> - <item> - <key> <string>title</string> </key> - <value> <string>Default SQL Catalog</string> </value> - </item> - <item> - <key> <string>truncate</string> </key> - <value> <int>0</int> </value> - </item> - <item> - <key> <string>unicode</string> </key> - <value> <int>0</int> </value> - </item> - <item> - <key> <string>whitespace_preserve</string> </key> - <value> <int>0</int> </value> - </item> - </dictionary> - </value> - </item> - </dictionary> - </pickle> - </record> -</ZopeData> diff --git a/product/ERP5Catalog/CatalogTool.py b/product/ERP5Catalog/CatalogTool.py index 572fd9040e926d9a6c7d782c805075e910f209a5..7b3677ea62aebcdff80687a65628d21dd1b56ea2 100644 --- a/product/ERP5Catalog/CatalogTool.py +++ b/product/ERP5Catalog/CatalogTool.py @@ -432,6 +432,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): # Update some required attributes to the portal_catalog object parent.portal_catalog.default_erp5_catalog_id = self.default_sql_catalog_id + del parent.portal_catalog.default_sql_catalog_id security.declarePublic('getPreferredSQLCatalogId') def getPreferredSQLCatalogId(self, id=None): @@ -441,7 +442,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/Tool/ERP5CatalogTool.py b/product/ERP5Catalog/Tool/ERP5CatalogTool.py index c84cfbed91bde40583d15077ab94098b619a0a5a..90a80a849fd2959bcd09411b6b45eb02864da521 100644 --- a/product/ERP5Catalog/Tool/ERP5CatalogTool.py +++ b/product/ERP5Catalog/Tool/ERP5CatalogTool.py @@ -113,23 +113,18 @@ class ERP5CatalogTool(BaseTool, CMFCore_CatalogTool): def _bootstrap(self): pass - def _setDefaultErp5CatalogId(self, value): - """ - Override this setter function so as to keep default_sql_catalog_id - and default_erp5_catalog_id same for portal_catalog after everyhting has - been migrated to erp5 portal_catalog - """ - self._baseSetDefaultErp5CatalogId(value) - self._baseSetDefaultSqlCatalogId(value) + def getDefaultSqlCatalogId(self): + return self.default_erp5_catalog_id - def _edit(self, **kw): + def _setDefaultSqlCatalogId(self, value): """ - Override to update both default_sql_catalog_id and default_erp5_catalog_id - in same edit + Function to maintain compatibility between ZSQLCatalog and ERP5CatalogTool + + Notice that we update the attribute `default_erp5_catalog_id` here and not + the property. This is because there maybe cases(migration) whern we don't + have accessors defined and there we'll need the attribute. """ - BaseTool._edit(self, **kw) - value = self.getDefaultErp5CatalogId() - self._setDefaultErp5CatalogId(value) + self.default_erp5_catalog_id = value # Filter content (ZMI)) def filtered_meta_types(self, user=None): @@ -173,6 +168,9 @@ class ERP5CatalogTool(BaseTool, CMFCore_CatalogTool): return self._getOb(id, default_value) + security.declarePublic('getSQLCatalog') + getSQLCatalog = getERP5Catalog # For compatibilty + security.declarePrivate('reindexCatalogObject') def reindexCatalogObject(self, object, idxs=None, sql_catalog_id=None,**kw): '''Update catalog after object data has changed. diff --git a/product/ERP5Catalog/tests/testERP5Catalog.py b/product/ERP5Catalog/tests/testERP5Catalog.py index 51049f36f9d06b064da740dafe71f6d59281fa57..2f4a7531a5e0953a58c7916a8767916f8c1523e0 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 71c9d0f1bcd151cddb7a02e08b82c1015e6de9be..3abc5f94ce43e617ac68d27973de524808906155 100644 --- a/product/ZSQLCatalog/ZSQLCatalog.py +++ b/product/ZSQLCatalog/ZSQLCatalog.py @@ -197,19 +197,22 @@ class ZCatalog(Folder, Persistent, Implicit): def getSQLCatalogIdList(self): return self.objectIds(spec=('SQLCatalog',)) + def getDefaultSqlCatalogId(self): + return self.default_sql_catalog_id + 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] else: return default_value - id = self.default_sql_catalog_id + id = self.getDefaultSqlCatalogId() return self._getOb(id, default_value) @@ -256,7 +259,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 +286,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 +384,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. @@ -402,6 +405,12 @@ class ZCatalog(Folder, Persistent, Implicit): if sql_connection_id_dict is not None: self.changeSQLConnectionIds(self.portal_skins, sql_connection_id_dict) + def _setDefaultSqlCatalogId(self, value): + ''' + Separate this part for compatibilty between CatalogTool and ERP5CatalogTool + ''' + self.default_sql_catalog_id = value + security.declareProtected(manage_zcatalog_entries, 'manage_hotReindexAll') def manage_hotReindexAll(self, source_sql_catalog_id, destination_sql_catalog_id, @@ -453,7 +462,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.')