Remove unnecessary lines from notify_content_object_moved event subscriber function.

svn path=/plone.app.discussion/trunk/; revision=50944
This commit is contained in:
Timo Stollenwerk 2011-07-04 07:07:42 +00:00
parent b7dad192d5
commit 50641ac6cc

View File

@ -220,26 +220,21 @@ def notify_content_object_deleted(obj, event):
def notify_content_object_moved(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 \ if event.oldParent is None or event.newParent is None \
or event.oldName is None or event.newName is None \ or event.oldName is None or event.newName is None \
or event.oldParent == event.newParent: or event.oldParent == event.newParent:
return return
# Remove comments at the old location from catalog
old_path = "%s/%s" % ('/'.join(event.oldParent.getPhysicalPath()),
event.oldName, )
new_path = '/'.join(obj.getPhysicalPath())
obj.__of__(event.newParent)
conversation = IConversation(obj)
catalog = getToolByName(obj, 'portal_catalog') catalog = getToolByName(obj, 'portal_catalog')
from Acquisition import *
for brain in catalog.searchResults(portal_type = 'Discussion Item'): for brain in catalog.searchResults(portal_type = 'Discussion Item'):
catalog.uncatalog_object(brain.getPath()) catalog.uncatalog_object(brain.getPath())
# Reindex comment at the new location
conversation = IConversation(obj)
for comment in conversation.getComments(): for comment in conversation.getComments():
comment.__parent__.__parent__.__of__(event.newParent)
comment.__parent__.__parent__.__parent__ = event.newParent comment.__parent__.__parent__.__parent__ = event.newParent
catalog.reindexObject(aq_base(comment)) catalog.reindexObject(aq_base(comment))
catalog.catalog_object(aq_base(comment))
def notify_user(obj, event): def notify_user(obj, event):