Commit 17b1272d authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_config: Move all attributes to sub-objects and donot reindex them

parent 0cd284ed
...@@ -278,7 +278,9 @@ class BusinessManager(Folder): ...@@ -278,7 +278,9 @@ class BusinessManager(Folder):
imported_manager = connection.importFile(file) imported_manager = connection.importFile(file)
self.title = imported_manager.title self.title = imported_manager.title
for obj in imported_manager.objectValues(): for obj in imported_manager.objectValues():
delattr(obj, '__ac_local_roles__')
self._setObject(obj.getId(), aq_base(obj)) self._setObject(obj.getId(), aq_base(obj))
obj.isIndexable = ConstantGetter('isIndexable', value=False)
self.setProperty('template_path_list', imported_manager.getProperty('template_path_list')) self.setProperty('template_path_list', imported_manager.getProperty('template_path_list'))
def __add__(self, other): def __add__(self, other):
...@@ -674,7 +676,8 @@ class BusinessItem(XMLObject): ...@@ -674,7 +676,8 @@ class BusinessItem(XMLObject):
# XXX: '_recursiveRemoveUid' is not working as expected # XXX: '_recursiveRemoveUid' is not working as expected
_recursiveRemoveUid(obj) _recursiveRemoveUid(obj)
obj = aq_base(obj) obj = aq_base(obj)
self._setObject(obj.getId(), obj) obj.isIndexable = ConstantGetter('isIndexable', value=False)
self._setObject(obj.getId(), obj, suppress_events=True)
except AttributeError: except AttributeError:
# In case the object doesn't exist, just pass without raising error # In case the object doesn't exist, just pass without raising error
pass pass
...@@ -783,13 +786,18 @@ class BusinessItem(XMLObject): ...@@ -783,13 +786,18 @@ class BusinessItem(XMLObject):
# install object # install object
obj = self.objectValues()[0] obj = self.objectValues()[0]
obj = obj._getCopy(container) obj = obj._getCopy(container)
container._setObject(object_id, obj) # Before making `obj` a sub-object of `container`, we should the acquired
obj = container._getOb(object_id) # roles on obj
obj.isIndexable = ConstantGetter('isIndexable', value=False) obj.isIndexable = ConstantGetter('isIndexable', value=False)
delattr(obj, '__ac_local_roles__')
container._setObject(object_id, obj, suppress_events=True)
obj = container._getOb(object_id)
"""
aq_base(obj).uid = portal.portal_catalog.newUid() aq_base(obj).uid = portal.portal_catalog.newUid()
del obj.isIndexable del obj.isIndexable
if getattr(aq_base(obj), 'reindexObject', None) is not None: if getattr(aq_base(obj), 'reindexObject', None) is not None:
obj.reindexObject() obj.reindexObject()
"""
def unrestrictedResolveValue(self, context=None, path='', default=_MARKER, def unrestrictedResolveValue(self, context=None, path='', default=_MARKER,
restricted=0): restricted=0):
......
...@@ -46,6 +46,7 @@ from Products.ERP5Type.Tool.BaseTool import BaseTool ...@@ -46,6 +46,7 @@ from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ERP5Type.Cache import transactional_cached from Products.ERP5Type.Cache import transactional_cached
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5.Document.BusinessTemplate import BusinessTemplateMissingDependency from Products.ERP5.Document.BusinessTemplate import BusinessTemplateMissingDependency
from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
from Products.ERP5.genbt5list import generateInformation from Products.ERP5.genbt5list import generateInformation
from Acquisition import aq_base from Acquisition import aq_base
from tempfile import mkstemp, mkdtemp from tempfile import mkstemp, mkdtemp
...@@ -1700,7 +1701,9 @@ class TemplateTool (BaseTool): ...@@ -1700,7 +1701,9 @@ class TemplateTool (BaseTool):
title='Old Installation State', title='Old Installation State',
) )
for item in combined_installed_path_item: for item in combined_installed_path_item:
old_installation_state._setObject(item.getId(), aq_base(item)) item.isIndexable = ConstantGetter('isIndexable', value=False)
old_installation_state._setObject(item.getId(), aq_base(item),
suppress_events=True)
forbidden_bm_title_list = ['Old Installation State',] forbidden_bm_title_list = ['Old Installation State',]
for bm in bm_list: for bm in bm_list:
...@@ -1722,7 +1725,9 @@ class TemplateTool (BaseTool): ...@@ -1722,7 +1725,9 @@ class TemplateTool (BaseTool):
) )
for item in combined_new_path_item: for item in combined_new_path_item:
new_installation_state._setObject(item.getId(), aq_base(item)) item.isIndexable = ConstantGetter('isIndexable', value=False)
new_installation_state._setObject(item.getId(), aq_base(item),
suppress_events=True)
# Create installation process, which have the changes to be made in the # Create installation process, which have the changes to be made in the
# OFS during installation. Importantly, it should also be a Business Manager # OFS during installation. Importantly, it should also be a Business Manager
...@@ -1772,7 +1777,9 @@ class TemplateTool (BaseTool): ...@@ -1772,7 +1777,9 @@ class TemplateTool (BaseTool):
to_install_path_item_list.append(item) to_install_path_item_list.append(item)
for item in to_install_path_item_list: for item in to_install_path_item_list:
installation_process._setObject(item.getId(), aq_base(item)) item.isIndexable = ConstantGetter('isIndexable', value=False)
installation_process._setObject(item.getId(), aq_base(item),
suppress_events=True)
error_list = self.compareOldStateToOFS(installation_process, old_installation_state) error_list = self.compareOldStateToOFS(installation_process, old_installation_state)
......
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