[Zope-CMF] Problem with discussions and PortalContentFolder

Tres Seaver tseaver@zope.com
Wed, 16 Jan 2002 07:07:26 -0500


Pieter Claerhout wrote:

> Hello,
> 
> I have a small problem with PortalContentFolder and discussions. I have set
> up a a PortalContentFolder type in my CMF installation that only allows you
> to add images. I attached some special actions to that folder so that it
> looks and reacts like a photo album.
> 
> All works fine, except for one thing. I allowed discussions on images, but
> everytime I reply on an image that is in a PortalContentFolder, the comment
> gets added to the folder instead of to the image. My guess is that this is
> caused by the fact that the PortalContentFolder is actually an object, and
> not a real folder. If I try the same thing on an image that is in a normal
> folder, all works fine.
> 
> Is this a known thing? If so, is there a way to get around it?

The issue here is that the discussion tool presumes that folders

will not be discussable.  The key method is in the 'portal_discussion'

tool (CMFDefault.DiscussionTool)::

     def getDiscussionFor(self, content):
         """
             Return the talkback for content, creating it if need be.
         """
         if not self.isDiscussionAllowedFor( content ):
             raise DiscussionNotAllowed

         talkback = getattr( content, 'talkback', None )
         if not talkback:
             talkback = self._createDiscussionFor( content )

         return talkback

This method uses 'getattr' on content without unwrapping it, and
hence can acquire 'talkback' from its container.  A patch would be
to unwrap the object, e.g.::

         talkback = getattr( aq_base( content ), 'talkback', None )

Your only workaround in the near term would be to modify the tool
with this patch (or else have your folder class call '_createDiscussionFor'
on objects as they are added to it).

Please submit this as a tracker issue:

   http://www.zope.org/Products/PTK/Tracker

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com