Commit c426efb9 authored by Ayush Tiwari's avatar Ayush Tiwari

erp5_catalog: Naming changes in migrateSQLCatalogToERP5Catalog as per context of the function

parent 658dd8de
......@@ -1704,7 +1704,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
# Getting ERP5 Catalog Tool
catalog_tool = self.portal_catalog
sql_catalog = catalog_tool.getSQLCatalog()
new_id = 'erp5_mysql_innodb_new'
erp5_catalog_id = 'erp5_mysql_innodb_new'
# If there is no default SQL Catalog installed already, add a warning log
# in ERP5Site and break the migration
if not sql_catalog:
......@@ -1714,15 +1714,15 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
return
if not isinstance(sql_catalog, ERP5Catalog):
if new_id not in catalog_tool.objectIds():
if erp5_catalog_id not in catalog_tool.objectIds():
# Create new ERP5Catalog object if it doesn't exist
catalog_tool.manage_addProduct['ERP5Catalog'].manage_addERP5Catalog(
id = new_id,
id = erp5_catalog_id,
title = '')
new_erp5_catalog = catalog_tool._getOb(new_id)
erp5_catalog = catalog_tool._getOb(erp5_catalog_id)
# No need to migrate if the new_erp5_catalog is not an object of ERP5Catlog
if not isinstance(new_erp5_catalog, ERP5Catalog):
# No need to migrate if the erp5_catalog is not an object of ERP5Catlog
if not isinstance(erp5_catalog, ERP5Catalog):
return
# Copy-paste objects from SQLCatalog to ERP5Catalog
......@@ -1730,14 +1730,14 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
ob = sql_catalog._getOb(id)
# Check if the object is copyable and that it doesn't already exist
# The copying attributes are from OFS.CopySupport
if hasattr(ob, '_canCopy') and not new_erp5_catalog.has_key(id):
# Get a copy of object for new conainer, i.e. new_erp5_catalog
ob = ob._getCopy(new_erp5_catalog)
if hasattr(ob, '_canCopy') and not erp5_catalog.has_key(id):
# Get a copy of object for new conainer, i.e. erp5_catalog
ob = ob._getCopy(erp5_catalog)
ob._setId(id)
# Set the copied object in the new_erp5_catalog
new_erp5_catalog._setObject(id, ob)
ob = new_erp5_catalog._getOb(id)
ob._postCopy(new_erp5_catalog, op=0)
# Set the copied object in the erp5_catalog
erp5_catalog._setObject(id, ob)
ob = erp5_catalog._getOb(id)
ob._postCopy(erp5_catalog, op=0)
# Update properties list for the new catalog from the SQLCatalog
# Not an efficient way to carry this
......@@ -1747,11 +1747,11 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
# https://lab.nexedi.com/nexedi/erp5/blob/198df7021a17725e81ab930015c3c618e94263db/product/ERP5Type/Base.py#L3531
if not property_id == 'title':
value = getattr(sql_catalog, property_id)
new_erp5_catalog._updateProperty(id=property_id, value=value)
erp5_catalog._updateProperty(id=property_id, value=value)
# Update default erp5 catalog id, everytime we run migration
# ERP5 Catalog(basically when this fucntion is called while creating ERP5Site)
catalog_tool.default_erp5_catalog_id = new_id
catalog_tool.default_erp5_catalog_id = erp5_catalog_id
Globals.InitializeClass(ERP5Site)
......
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