Commit 8085ff34 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Even if region is a sub Category of Base Category region, relative Url must be...

Even if region is a sub Category of Base Category region, relative Url must be stripped, because the behaviour should be stable regardless of such category existence and it is also good for performance.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45789 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 03c899d2
...@@ -1748,15 +1748,9 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1748,15 +1748,9 @@ class CategoryTool( UniqueObject, Folder, Base ):
path): path):
"""Specific Handling to remove duplicated base_categories in path """Specific Handling to remove duplicated base_categories in path
values like in following example: 'region/region/europe/west'. values like in following example: 'region/region/europe/west'.
If duplicated id is a real subobject of base_category,
then the path its keept as it is
""" """
splitted_path = path.split('/', 2) splitted_path = path.split('/', 2)
if len(splitted_path) >= 2 and base_category_id == splitted_path[1]: if len(splitted_path) >= 2 and base_category_id == splitted_path[1]:
# It needs to be checked.
base_category_value = self._getOb(base_category_id)
if base_category_value._getOb(splitted_path[1], None) is None:
# Duplicate found, strip len(base_category_id + '/') in path # Duplicate found, strip len(base_category_id + '/') in path
path = path[len(base_category_id)+1:] path = path[len(base_category_id)+1:]
return path return path
......
...@@ -1024,8 +1024,8 @@ class TestCMFCategory(ERP5TypeTestCase): ...@@ -1024,8 +1024,8 @@ class TestCMFCategory(ERP5TypeTestCase):
are cleaned up by Getters to avoid accessing base_category through are cleaned up by Getters to avoid accessing base_category through
implicit Acquisition. implicit Acquisition.
If region is a sub Category of Base Category region, Even if region is a sub Category of Base Category region,
Relative Url must not be stripped Relative Url must be stripped.
""" """
portal_categories = self.getCategoriesTool() portal_categories = self.getCategoriesTool()
organisation = self.getOrganisationModule().newContent( organisation = self.getOrganisationModule().newContent(
...@@ -1049,13 +1049,13 @@ class TestCMFCategory(ERP5TypeTestCase): ...@@ -1049,13 +1049,13 @@ class TestCMFCategory(ERP5TypeTestCase):
new_region = new_region.newContent(portal_type='Category', id='europe') new_region = new_region.newContent(portal_type='Category', id='europe')
new_region = new_region.newContent(portal_type='Category', id='west') new_region = new_region.newContent(portal_type='Category', id='west')
self.assertEquals(organisation.getRegion(), 'region/europe/west') self.assertEquals(organisation.getRegion(), 'europe/west')
self.assertEquals(organisation.getRegionList(), ['region/europe/west']) self.assertEquals(organisation.getRegionList(), ['europe/west'])
self.assertEquals(organisation.getRegionValue().getPortalType(), 'Category') self.assertEquals(organisation.getRegionValue().getPortalType(), 'Category')
self.assertNotEquals(organisation.getRegionValue(), old_west_region) self.assertEquals(organisation.getRegionValue(), old_west_region)
self.assertEquals(person.getRegion(), 'region/europe/west') self.assertEquals(person.getRegion(), 'europe/west')
self.assertEquals(person.getRegionList(), ['region/europe/west']) self.assertEquals(person.getRegionList(), ['europe/west'])
# Let's continue with resource because its ID conflict with # Let's continue with resource because its ID conflict with
# "traversing namespaces" names # "traversing namespaces" names
......
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