How to override enable_conversation added.

This commit is contained in:
Timo Stollenwerk 2012-01-25 15:57:10 +01:00
parent 80d70bbf08
commit 943661cf42
6 changed files with 96 additions and 87 deletions

View File

@ -1,6 +1,6 @@
================================================================================ ===============================================================================
How to override plone.app.discussion's comments viewlet How to override plone.app.discussion's comments viewlet
================================================================================ ===============================================================================
This document explains how to override the plone.app.discussion comments This document explains how to override the plone.app.discussion comments
viewlet that controls the way existing comments are displayed. viewlet that controls the way existing comments are displayed.

View File

@ -1,12 +1,25 @@
==============================================================================
Howto override the enable_conversation method.
==============================================================================
configure.zcml:: plone.app.discussion way to decide if commenting is enabled on a content
object can be quite complex and cumbersome due to the need to be backward
compatible with the way the old commenting system in Plone (<4.1) worked.
The comments viewlet calls the enabled method of the ConversationView to
decide if the add comment form should show up:
.. literalinclude:: ../../../plone/app/discussion/browser/conversation.py
:language: python
:pyobject: ConversationView
If you want to override this behavior, you just have to create your own enabled method. To do so, we first have to register our custom
ConversationView by overriding the existing one in our configure.zcml::
<configure <configure
xmlns="http://namespaces.zope.org/zope" xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser" xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone" i18n_domain="mycustompackage.discussion">
xmlns:grok="http://namespaces.zope.org/grok"
i18n_domain="freitag.behavior.allowdiscussion">
<!-- Override plone.app.discussion's conversation view --> <!-- Override plone.app.discussion's conversation view -->
<browser:page <browser:page
@ -18,21 +31,16 @@ configure.zcml::
</configure> </configure>
conversation.py Now we implement the conversation view with a single "enable" method in
conversation.py::
from zope.component import queryUtility from zope.component import queryUtility
from plone.registry.interfaces import IRegistry from plone.registry.interfaces import IRegistry
from Acquisition import aq_base
from Acquisition import aq_chain
from Acquisition import aq_inner from Acquisition import aq_inner
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.CMFCore.interfaces import IFolderish
from Products.CMFPlone.interfaces import IPloneSiteRoot
from Products.CMFPlone.interfaces import INonStructuralFolder
from plone.app.discussion.interfaces import IDiscussionSettings from plone.app.discussion.interfaces import IDiscussionSettings

View File

@ -1,6 +1,6 @@
================================================================================ ===============================================================================
Howto write a custom email notification Howto write a custom email notification
================================================================================ ===============================================================================
This document explains how to write a custom email notification for This document explains how to write a custom email notification for
plone.app.discussion. plone.app.discussion.

View File

@ -6,3 +6,4 @@ Howtos
:maxdepth: 1 :maxdepth: 1
howto_extend_the_comment_form.txt howto_extend_the_comment_form.txt
howto_override_enable_conversation.txt