Can not activate discussions on Plone Dexterity types (folderish)

隐身守侯 提交于 2019-12-06 02:16:41

问题


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?


回答1:


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.




回答2:


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.




回答3:


As David and Victor already pointed out, you can just override the enable method of the conversation class. I would recommend using the following approach which is a bit cleaner than monkey patching the conversation class:

https://github.com/plone/plone.app.discussion/blob/master/docs/source/howtos/howto_override_enable_conversation.txt

I also added support for dexterity types to plone.app.discussion recently, so as soon as there is a new release you won't need to customize the conversation class any longer:

https://github.com/plone/plone.app.discussion/commit/0e587a7d8536125acdd3bd385e880b60d6aec28e

Note that this method supports commenting ON folderish objects. There is no support to enable/disable commenting for objects INSIDE a folderish object yet.

In case you want to be able to switch on/off commenting with a behavior field/widget:

https://github.com/plone/plone.app.dexterity/commit/0573df4f265a39da9efae44e605e3815729457d7

This will hopefully make it into the next plone.app.dexterity release as well.




回答4:


I solved in configure.zcml:

<interface interface="Products.CMFPlone.interfaces.INonStructuralFolder" />

<class class="Products.PloneHelpCenter.types.Definition.HelpCenterDefinition">
  <implements interface="Products.CMFPlone.interfaces.INonStructuralFolder" />
</class>

UPDATE: this is not a good idea. I had problems with missing Add menu for each content type having this fix.



来源:https://stackoverflow.com/questions/10402918/can-not-activate-discussions-on-plone-dexterity-types-folderish

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!