From 50641ac6cc846b6e5b58f773e4b9f2cdd2709292 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Mon, 4 Jul 2011 07:07:42 +0000 Subject: [PATCH] Remove unnecessary lines from notify_content_object_moved event subscriber function. svn path=/plone.app.discussion/trunk/; revision=50944 --- plone/app/discussion/comment.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/plone/app/discussion/comment.py b/plone/app/discussion/comment.py index 40d4d0d..fc89c77 100644 --- a/plone/app/discussion/comment.py +++ b/plone/app/discussion/comment.py @@ -220,26 +220,21 @@ def notify_content_object_deleted(obj, event): def notify_content_object_moved(obj, event): + """Update all comments of a content object that has been moved. + """ if event.oldParent is None or event.newParent is None \ or event.oldName is None or event.newName is None \ or event.oldParent == event.newParent: return - - old_path = "%s/%s" % ('/'.join(event.oldParent.getPhysicalPath()), - event.oldName, ) - new_path = '/'.join(obj.getPhysicalPath()) - obj.__of__(event.newParent) - conversation = IConversation(obj) + # Remove comments at the old location from catalog catalog = getToolByName(obj, 'portal_catalog') - from Acquisition import * for brain in catalog.searchResults(portal_type = 'Discussion Item'): catalog.uncatalog_object(brain.getPath()) + # Reindex comment at the new location + conversation = IConversation(obj) for comment in conversation.getComments(): - comment.__parent__.__parent__.__of__(event.newParent) comment.__parent__.__parent__.__parent__ = event.newParent catalog.reindexObject(aq_base(comment)) - catalog.catalog_object(aq_base(comment)) - def notify_user(obj, event):