[CMF-checkins] SVN: CMF/trunk/ - CMFDefault.DiscussionTool: Ensure that isDiscussionAllowedFor will

Jens Vagelpohl jens at dataflake.org
Sat Feb 18 15:57:54 EST 2006


Log message for revision 41677:
  - CMFDefault.DiscussionTool: Ensure that isDiscussionAllowedFor will
    not accidentally acquire discussion settings from the content
    object's parent.
    (http://www.zope.org/Collectors/CMF/398)
  

Changed:
  U   CMF/trunk/CMFCore/tests/base/dummy.py
  U   CMF/trunk/CMFDefault/DiscussionTool.py
  U   CMF/trunk/CMFDefault/tests/test_DiscussionTool.py
  U   CMF/trunk/HISTORY.txt

-=-
Modified: CMF/trunk/CMFCore/tests/base/dummy.py
===================================================================
--- CMF/trunk/CMFCore/tests/base/dummy.py	2006-02-18 20:57:23 UTC (rev 41676)
+++ CMF/trunk/CMFCore/tests/base/dummy.py	2006-02-18 20:57:54 UTC (rev 41677)
@@ -78,6 +78,9 @@
     def queryMethodID(self, alias, default=None, context=None):
         return self._actions.get(alias, default)
 
+    def allowDiscussion(self):
+        return False
+
 class DummyContent( PortalContent, Item ):
     """
     A Dummy piece of PortalContent

Modified: CMF/trunk/CMFDefault/DiscussionTool.py
===================================================================
--- CMF/trunk/CMFDefault/DiscussionTool.py	2006-02-18 20:57:23 UTC (rev 41676)
+++ CMF/trunk/CMFDefault/DiscussionTool.py	2006-02-18 20:57:54 UTC (rev 41677)
@@ -103,7 +103,7 @@
     def isDiscussionAllowedFor( self, content ):
         """ Get boolean indicating whether discussion is allowed for content.
         """
-        if hasattr( content, 'allow_discussion' ):
+        if hasattr( aq_base(content), 'allow_discussion' ):
             return bool(content.allow_discussion)
         typeInfo = getToolByName(self, 'portal_types').getTypeInfo( content )
         if typeInfo:

Modified: CMF/trunk/CMFDefault/tests/test_DiscussionTool.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_DiscussionTool.py	2006-02-18 20:57:23 UTC (rev 41676)
+++ CMF/trunk/CMFDefault/tests/test_DiscussionTool.py	2006-02-18 20:57:54 UTC (rev 41677)
@@ -36,6 +36,7 @@
         self.site = DummySite('site')
         self.site._setObject( 'portal_discussion', self._makeOne() )
         self.site._setObject( 'portal_membership', DummyTool() )
+        self.site._setObject( 'portal_types', DummyTool() )
 
     def test_z2interfaces(self):
         from Interface.Verify import verifyClass
@@ -72,6 +73,16 @@
         dtool.overrideDiscussionFor(foo, None)
         self.failIf( hasattr(foo.aq_base, 'allow_discussion') )
 
+    def test_isDiscussionAllowedFor(self):
+        # Test for Collector issue #398 (allow_discussion wrongly
+        # acquired and used from parent)
+        dtool = self.site.portal_discussion
+        foo = self.site._setObject( 'foo', DummyFolder() )
+        baz = foo._setObject( 'baz', DummyFolder() )
+        dtool.overrideDiscussionFor(foo, 1)
+
+        self.failIf(dtool.isDiscussionAllowedFor(baz))
+
     def test_getDiscussionFor(self):
         dtool = self.site.portal_discussion
         foo = self.site._setObject( 'foo', DummyFolder() )

Modified: CMF/trunk/HISTORY.txt
===================================================================
--- CMF/trunk/HISTORY.txt	2006-02-18 20:57:23 UTC (rev 41676)
+++ CMF/trunk/HISTORY.txt	2006-02-18 20:57:54 UTC (rev 41677)
@@ -41,6 +41,11 @@
 
   Bug Fixes
 
+    - CMFDefault.DiscussionTool: Ensure that isDiscussionAllowedFor will
+      not accidentally acquire discussion settings from the content
+      object's parent.
+      (http://www.zope.org/Collectors/CMF/398)
+
     - CMFDefault.RegistrationTool: Adding single quotes to the allowed
       characters in the local part of an email address.
       (http://www.zope.org/Collectors/CMF/401)



More information about the CMF-checkins mailing list