[CMF-checkins] SVN: CMF/trunk/CMFDefault/ -
CMFDefault.DiscussionItem: Deleting a discussion reply would not
Jens Vagelpohl
jens at dataflake.org
Sun Jan 22 09:55:13 EST 2006
Log message for revision 41407:
- CMFDefault.DiscussionItem: Deleting a discussion reply would not
recurse and left items below the deleted reply still cataloged
(http://www.zope.org/Collectors/CMF/391)
Changed:
U CMF/trunk/CMFDefault/DiscussionItem.py
U CMF/trunk/CMFDefault/tests/test_Discussions.py
-=-
Modified: CMF/trunk/CMFDefault/DiscussionItem.py
===================================================================
--- CMF/trunk/CMFDefault/DiscussionItem.py 2006-01-22 14:54:36 UTC (rev 41406)
+++ CMF/trunk/CMFDefault/DiscussionItem.py 2006-01-22 14:55:13 UTC (rev 41407)
@@ -299,11 +299,8 @@
my_replies = reply.talkback.getReplies()
for my_reply in my_replies:
my_reply_id = my_reply.getId()
- if hasattr( my_reply, 'unindexObject' ):
- my_reply.unindexObject()
+ self.deleteReply(my_reply_id)
- del self._container[my_reply_id]
-
if hasattr( reply, 'unindexObject' ):
reply.unindexObject()
Modified: CMF/trunk/CMFDefault/tests/test_Discussions.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Discussions.py 2006-01-22 14:54:36 UTC (rev 41406)
+++ CMF/trunk/CMFDefault/tests/test_Discussions.py 2006-01-22 14:55:13 UTC (rev 41407)
@@ -267,9 +267,11 @@
def test_deleteReplies(self):
dtool = self.site.portal_discussion
+ ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
test = self._makeDummyContent('test')
test.allow_discussion = 1
+ # Create a structure 6 levels deep for testing
talkback = dtool.getDiscussionFor(test)
id1 = talkback.createReply(title='test1', text='blah')
reply1 = talkback.getReply(id1)
@@ -278,20 +280,38 @@
reply2 = talkback1.getReply(id2)
talkback2 = dtool.getDiscussionFor(reply2)
id3 = talkback2.createReply(title='test3', text='blah')
- reply3 = talkback.getReply(id3)
+ reply3 = talkback2.getReply(id3)
talkback3 = dtool.getDiscussionFor(reply3)
+ id4 = talkback3.createReply(title='test4', text='blah')
+ reply4 = talkback3.getReply(id4)
+ talkback4 = dtool.getDiscussionFor(reply4)
+ id5 = talkback4.createReply(title='test5', text='blah')
+ reply5 = talkback4.getReply(id5)
+ talkback5 = dtool.getDiscussionFor(reply5)
+ id6 = talkback5.createReply(title='test6', text='blah')
+ reply6 = talkback5.getReply(id6)
+ talkback6 = dtool.getDiscussionFor(reply6)
+
self.assertEqual(len(talkback.getReplies()), 1)
self.assertEqual(len(talkback1.getReplies()), 1)
self.assertEqual(len(talkback2.getReplies()), 1)
- self.assertEqual(len(talkback3.getReplies()), 0)
+ self.assertEqual(len(talkback3.getReplies()), 1)
+ self.assertEqual(len(talkback4.getReplies()), 1)
+ self.assertEqual(len(talkback5.getReplies()), 1)
+ self.assertEqual(len(talkback6.getReplies()), 0)
+ self.assertEqual(len(ctool), 6)
- talkback.deleteReply(id2)
+ talkback3.deleteReply(id4)
self.assertEqual(len(talkback.getReplies()), 1)
- reply1 = talkback.getReply(id1)
- talkback1 = dtool.getDiscussionFor(reply1)
- self.assertEqual(len(talkback.getReplies()), 1)
- self.assertEqual(len(talkback1.getReplies()), 0)
+ self.assertEqual(len(talkback1.getReplies()), 1)
+ self.assertEqual(len(talkback2.getReplies()), 1)
+ self.assertEqual(len(talkback3.getReplies()), 0)
+ self.assertEqual(len(ctool), 3)
+ talkback.deleteReply(id1)
+ self.assertEqual(len(talkback.getReplies()), 0)
+ self.assertEqual(len(ctool), 0)
+
def test_newTalkbackIsWrapped(self):
test = self._makeDummyContent('test')
test.allow_discussion = 1
More information about the CMF-checkins
mailing list