| Last change
                  on this file was
                  1,
                  checked in by myroslav, 20 years ago | 
        
          | 
Building directory structure
 | 
        | File size:
            878 bytes | 
      
      
        
  | Line |  | 
|---|
| 1 | ## Script (Python) "prefs_recent_comments_delete" | 
|---|
| 2 | ##bind container=container | 
|---|
| 3 | ##bind context=context | 
|---|
| 4 | ##bind namespace= | 
|---|
| 5 | ##bind script=script | 
|---|
| 6 | ##bind subpath=traverse_subpath | 
|---|
| 7 | ##parameters= | 
|---|
| 8 | ##title= | 
|---|
| 9 | ## | 
|---|
| 10 |  | 
|---|
| 11 | from Products.CMFCore.utils import getToolByName | 
|---|
| 12 | portal_discussion = getToolByName(context, "portal_discussion") | 
|---|
| 13 | portal_catalog = getToolByName(context, "portal_catalog") | 
|---|
| 14 |  | 
|---|
| 15 | request = context.REQUEST | 
|---|
| 16 | comment_ids = request.get('ids') | 
|---|
| 17 |  | 
|---|
| 18 | for comment_id in comment_ids: | 
|---|
| 19 | comment = portal_catalog(id=comment_id,portal_type='Discussion Item')[0].getObject() | 
|---|
| 20 |  | 
|---|
| 21 | parent = comment.inReplyTo() | 
|---|
| 22 | if parent is not None: | 
|---|
| 23 | talkback = portal_discussion.getDiscussionFor(parent) | 
|---|
| 24 | else: | 
|---|
| 25 | talkback = parent = comment.aq_parent | 
|---|
| 26 |  | 
|---|
| 27 | talkback.deleteReply( comment_id ) | 
|---|
| 28 |  | 
|---|
| 29 | return state.set(portal_status_message='Comments was successfully deleted.') | 
|---|
| 30 |  | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.