[CMF-checkins] SVN: CMF/branches/1.6/C - CMFDefault.DiscussionTool:
Prevent an exception in edge cases
Jens Vagelpohl
jens at dataflake.org
Sun Nov 18 17:50:54 EST 2007
Log message for revision 81922:
- CMFDefault.DiscussionTool: Prevent an exception in edge cases
where the flag to allow discussions only exists at class level.
(https://bugs.launchpad.net/zope-cmf/+bug/162532)
Changed:
U CMF/branches/1.6/CHANGES.txt
U CMF/branches/1.6/CMFDefault/DiscussionTool.py
U CMF/branches/1.6/CMFDefault/tests/test_DiscussionTool.py
-=-
Modified: CMF/branches/1.6/CHANGES.txt
===================================================================
--- CMF/branches/1.6/CHANGES.txt 2007-11-18 17:02:16 UTC (rev 81921)
+++ CMF/branches/1.6/CHANGES.txt 2007-11-18 22:50:54 UTC (rev 81922)
@@ -2,6 +2,10 @@
Bug Fixes
+ - CMFDefault.DiscussionTool: Prevent an exception in edge cases
+ where the flag to allow discussions only exists at class level.
+ (https://bugs.launchpad.net/zope-cmf/+bug/162532)
+
- CMFCore.FSImage: Supply class-level defaults for 'alt', 'height',
and 'width', to avoid acquiring objects with the same names
(http://www.zope.org/Collectors/CMF/507)
Modified: CMF/branches/1.6/CMFDefault/DiscussionTool.py
===================================================================
--- CMF/branches/1.6/CMFDefault/DiscussionTool.py 2007-11-18 17:02:16 UTC (rev 81921)
+++ CMF/branches/1.6/CMFDefault/DiscussionTool.py 2007-11-18 22:50:54 UTC (rev 81922)
@@ -89,7 +89,11 @@
if allowDiscussion is None or allowDiscussion == 'None':
if hasattr( aq_base(content), 'allow_discussion'):
- del content.allow_discussion
+ try:
+ del content.allow_discussion
+ except AttributeError:
+ # https://bugs.launchpad.net/zope-cmf/+bug/162532
+ pass
else:
content.allow_discussion = bool(allowDiscussion)
Modified: CMF/branches/1.6/CMFDefault/tests/test_DiscussionTool.py
===================================================================
--- CMF/branches/1.6/CMFDefault/tests/test_DiscussionTool.py 2007-11-18 17:02:16 UTC (rev 81921)
+++ CMF/branches/1.6/CMFDefault/tests/test_DiscussionTool.py 2007-11-18 22:50:54 UTC (rev 81922)
@@ -80,6 +80,18 @@
dtool.overrideDiscussionFor(foo, None)
self.failIf( hasattr(foo.aq_base, 'allow_discussion') )
+ # https://bugs.launchpad.net/zope-cmf/+bug/162532: Don't break
+ # if allow_discussion only exists at the class level
+ class DummyContent:
+ allow_discussion = False
+ def getId(self): return 'dummy'
+
+ dummy = DummyContent()
+ try:
+ dtool.overrideDiscussionFor(dummy, None)
+ except AttributeError:
+ self.fail('Launchpad issue 162532: AttributeError raised')
+
def test_isDiscussionAllowedFor(self):
# Test for Collector issue #398 (allow_discussion wrongly
# acquired and used from parent)
More information about the CMF-checkins
mailing list