Back to index

plone3  3.1.7
getReplyReplies.py
Go to the documentation of this file.
00001 ## Script (Python) "getReplyReplies"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=obj
00008 ##title=gets the replies to an object
00009 ##
00010 
00011 replies = []
00012 pd = container.portal_discussion
00013 
00014 from Products.CMFDefault.DiscussionTool import DiscussionNotAllowed
00015 try:
00016     pd.getDiscussionFor(obj)
00017 except DiscussionNotAllowed:
00018     # We tried to get discussions for an object that has not only
00019     # discussions turned off but also no discussion container.
00020     return []
00021 
00022 def getRs(obj, replies, counter):
00023     rs = pd.getDiscussionFor(obj).getReplies()
00024     if len(rs) > 0:
00025         rs = container.sort_modified_ascending(rs)
00026         for r in rs:
00027             replies.append({'depth':counter, 'object':r})
00028             getRs(r, replies, counter=counter + 1)
00029 
00030 getRs(obj, replies, 0)
00031 return replies