Aggregate Comments in Plone

Does anyone know if there is a way for me to aggregate comments made by people throughout a Plone site? I know how to turn comments/discussion on but is there a way to print or export them out into a text file or excel spreadsheet? Any help would be most appreciated. Thank you.

Plone 5.0.7 (5017)
CMF 2.2.10
Zope 2.13.26
Python 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
PIL 3.4.2 (Pillow)

Probably would have to be a script at least. It would iterate over all content items and output any comments on them. Haven’t heard of an add on that does that though.

Comments are standard Plone content items that can be search through the portal_catalog. Iterating over them and generating a CSV file or a text file is straight forward and not more than some lines of code.

-aj

1 Like

Thanks Kim and Andreas. So my next question will show my complete ignorance and lack of knowledge. I am familiar with extracting info from a MySQL database and output that information in any shape or form but I am completely clueless how to do so for a Zope database. Could you direct me to some references or examples to help me jump start this project? Thanks so much.

https://docs.plone.org/develop/plone.api/docs/content.html#content-find-example

Thanks so much, Andreas. I will give it a go and see what happens.

So this is what I have done so far:

  1. Created a page called "section" with comments. "Test" is my Plone site:
    Test/division/section
  2. Added a Python Script called "comments" in ZMI and placed it at Test//division/section:
    Appended some codes from to the Python Script:
# Import a standard function, and get the HTML request and response objects.
from Products.PythonScripts.standard import html_quote
request = container.REQUEST
response =  request.response

# Return a string identifying this script.
print "This is the", script.meta_type, '"%s"' % script.getId(),
if script.title:
    print "(%s)" % html_quote(script.title),
print "in", container.absolute_url()
return printed

from plone import api
portal = api.portal.get()
assert portal.id == 'Test'

from plone import api
documents = api.content.find(
    context=api.portal.get(), portal_type='Document')

I am sure I am doing something wrong because I am not see anything except for the default example that came with the script when I load Test/division/comments:

This is the Script (Python) "comments" in https://..../Test/division

Any advise would be most appreciated.

It's because your script doesn't print anything after finding the documents... you should add another print statement and then move the return printed line to the bottom of your script.

I am getting an Insufficient Privileges page even when logged in as a Manager. I am sure I am doing something wrong:

# Example code:
# Import a standard function, and get the HTML request and response objects.
    from Products.PythonScripts.standard import html_quote
    request = container.REQUEST
    response =  request.response

    # Return a string identifying this script.
    #print "This is the", script.meta_type, '"%s"' % script.getId(),
    #if script.title:
    #    print "(%s)" % html_quote(script.title),
    #print "in", container.absolute_url()

    from plone import api
    portal = api.portal.get()
    assert portal.id == 'Test'

    from plone import api
    documents = api.content.find(
        context=api.portal.get(), portal_type='Document')
    print documents

    return printed

Could it be this? from plone import api or perhaps the find() call isn't allowed in Script (Python) (TTW script).

Thanks Kim. If that is the case, where should this script go? Should it be in a Plone product. If so, where in the Plone product? Ultimately, I would like to be able to consolidate or capture all comments made within a folder or a site.

You could write it as a script on the file system and execute it like this
https://docs.plone.org/develop/plone/misc/commandline.html#id5