Commit 74d657ab authored by Jérome Perrin's avatar Jérome Perrin

do not iterrate on obj.objectIds() while deleting objects from obj when

removing subobjects in build, otherwise subcategories are included in
base categories.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7511 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c8969f9b
......@@ -431,7 +431,7 @@ class ObjectTemplateItem(BaseTemplateItem):
groups = deepcopy(obj.groups)
if id_list:
self.build_sub_objects(context, id_list, relative_url)
for id_ in id_list:
for id_ in list(id_list):
obj._delObject(id_)
if hasattr(aq_base(obj), 'groups'):
obj.groups = groups
......@@ -452,7 +452,7 @@ class ObjectTemplateItem(BaseTemplateItem):
groups = deepcopy(obj.groups)
if len(id_list) > 0:
self.build_sub_objects(context, id_list, relative_url)
for id_ in id_list:
for id_ in list(id_list):
obj._delObject(id_)
if hasattr(aq_base(obj), 'groups'):
obj.groups = groups
......@@ -759,7 +759,7 @@ class PathTemplateItem(ObjectTemplateItem):
if len(id_list) > 0:
if include_subobjects:
self.build_sub_objects(context, id_list, relative_url)
for id_ in id_list:
for id_ in list(id_list):
obj._delObject(id_)
if hasattr(aq_base(obj), 'groups'):
obj.groups = groups
......@@ -781,7 +781,7 @@ class CategoryTemplateItem(ObjectTemplateItem):
id_list = obj.objectIds()
if id_list:
self.build_sub_objects(context, id_list, relative_url)
for id_ in id_list:
for id_ in list(id_list):
obj._delObject(id_)
self._objects[relative_url] = obj
obj.wl_clearLocks()
......@@ -797,10 +797,10 @@ class CategoryTemplateItem(ObjectTemplateItem):
id_list = obj.objectIds()
if len(id_list) > 0 and include_sub_categories:
self.build_sub_objects(context, id_list, relative_url)
for id_ in id_list:
for id_ in list(id_list):
obj._delObject(id_)
else:
for id_ in id_list:
for id_ in list(id_list):
obj._delObject(id_)
self._objects[relative_url] = obj
obj.wl_clearLocks()
......
......@@ -1496,7 +1496,19 @@ class TestBusinessTemplate(ERP5TypeTestCase):
Check presence of trash tool
"""
self.failUnless(self.getSimulationTool() is not None)
def stepCheckSubobjectsNotIncluded(self, sequence=None,
sequence_list=None, **kw):
"""Check subobjects are not included in the base category.
"""
base_category_id = sequence.get('bc_id')
bt = sequence.get('current_bt')
# XXX maybe too low level
base_category_obj = bt._category_item._objects.get(
'portal_categories/%s' % base_category_id)
self.failUnless(base_category_obj is not None)
self.assertEquals(len(base_category_obj.objectIds()), 0)
# tests
def test_01_checkNewSite(self, quiet=0, run=run_all_test):
if not run: return
......@@ -2640,7 +2652,31 @@ class TestBusinessTemplate(ERP5TypeTestCase):
RemoveBusinessTemplate \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
sequence_list.play(self)
def test_21_CategoryIncludeSubobjects(self, quiet=0, run=run_all_test):
if not run: return
if not quiet:
message = 'Test Category includes subobjects'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ', 0, message)
sequence_list = SequenceList()
sequence_string = '\
CreateBaseCategory \
CreateCategories \
CreateSubCategories \
CreateNewBusinessTemplate \
UseExportBusinessTemplate \
AddBaseCategoryToBusinessTemplate \
BuildBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckSubobjectsNotIncluded \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
if __name__ == '__main__':
framework()
......
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