Commit 4931263d authored by Sebastien Robin's avatar Sebastien Robin

updateRelatedContent should be able to modify predicates


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2796 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9ea2aa58
...@@ -39,6 +39,8 @@ from OFS.Folder import Folder as OFS_Folder ...@@ -39,6 +39,8 @@ from OFS.Folder import Folder as OFS_Folder
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.CMFCore.PortalFolder import PortalFolder from Products.CMFCore.PortalFolder import PortalFolder
from Products.ERP5Type.CopySupport import CopyContainer from Products.ERP5Type.CopySupport import CopyContainer
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.Document import newTempBase
from zLOG import LOG from zLOG import LOG
...@@ -119,7 +121,26 @@ class CategoryTool(CopyContainer, CMFCategoryTool, BaseTool): ...@@ -119,7 +121,26 @@ class CategoryTool(CopyContainer, CMFCategoryTool, BaseTool):
security.declareProtected(Permissions.AccessContentsInformation, 'getUids') security.declareProtected(Permissions.AccessContentsInformation, 'getUids')
getUids = getCategoryParentUidList getUids = getCategoryParentUidList
def updateRelatedContent(self, context, previous_category_url, new_category_url):
"""
TODO: make this method resist to very large updates (ie. long transaction)
"""
CMFCategoryTool.updateRelatedContent(self,context,previous_category_url,new_category_url)
# We also need to udpate all predicates membership
domain_tool = getToolByName(context,'portal_domains')
portal_catalog = getToolByName(context,'portal_catalog')
kw = {}
kw['predicate_category.category_uid'] = context.getUid()
object_list = portal_catalog(**kw)
for predicate in [x.getObject() for x in object_list]:
membership_list = []
for category in predicate.getMembershipCriterionCategoryList():
new_category = self.updateRelatedCategory(category, previous_category_url, new_category_url)
membership_list.append(new_category)
predicate.setMembershipCriterionCategoryList(membership_list)
# We do not need to to things recursively since updateRelatedContent is already
# recursive.
InitializeClass( CategoryTool ) InitializeClass( CategoryTool )
#from Products.ERP5Type.Utils import monkeyPatch
#monkeyPatch(CMFCategoryTool,CategoryTool,exclude_list=['__init__'])
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