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
1 changed files with 5 additions and 10 deletions

View File

@ -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):