Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not activate discussions on Plone Dexterity types (folderish)

I have been working on a dexterity based plone application. I have created a couple of new types. This is what I did to activate comments on a specific dexterity content type named "activity_report":

In Plone Control Panel

In the Discussion section I enabled the following:

  • globally enable comments
  • enable anonymous comments

In the Types Section I chose the "Activity Report" type from the drop down and enabled the "Allow comments" option.

On the file system

In the FTI file activityreport.xml:

<property name="allow_discussion">True</property>

I have restarted the instance and even reinstalled the product, but I can not activate the comments section in the dexterity type.

It is worth mentioning that a standard type (ex. Page) can have the discussion module activated.

Is there something I am missing?

like image 528
jcuot Avatar asked May 01 '12 19:05

jcuot


2 Answers

plone.app.discussion currently disables commenting for all containers (see https://dev.plone.org/ticket/11245 for discussion).

I used a monkey patch like the following in one project to short-circuit the normal check and make sure that commenting was enabled for my folderish content type:

from Acquisition import aq_inner
from Products.highcountrynews.content.interfaces import IHCNNewsArticle
from plone.app.discussion.conversation import Conversation
old_enabled = Conversation.enabled
def enabled(self):
    parent = aq_inner(self.__parent__)
    if parent.portal_type == 'my_portal_type':
        return True
    return old_enabled(self)
Conversation.enabled = enabled

where 'my_portal_type' is, of course, the portal_type you want commenting enabled for.

like image 75
David Glick Avatar answered Sep 30 '22 18:09

David Glick


The David response is not accurate. The class to be monkeypatched is plone.app.discussion.browser.conversation.ConversationView :

from Acquisition import aq_inner
from plone.app.discussion.browser.conversation import ConversationView
old_enabled = ConversationView.enabled

def enabled(self):
    parent = aq_inner(self.__parent__)
    if parent.portal_type == 'My_type':
        return True
    return old_enabled(self)

It works for Plone 4.2 at least. However, thanks David for the hint.

like image 40
sneridagh Avatar answered Sep 30 '22 17:09

sneridagh