[Zope-CMF] overrideDiscussionFor() in discussion tool
Dieter Maurer
dieter at handshake.de
Sat May 8 14:36:32 EDT 2004
Tim Terlegård wrote at 2004-5-7 20:03 +0200:
>I get an error in a method in CMFDefault/DiscussionTool.py, CMF 1.4.2/3
>
>overrideDiscussionFor(self, content, allowDiscussion):
> ...
> if allowDiscussion is None or allowDiscussion == 'None':
> if hasattr(content, 'allow_discussion'):
> del content.allow_discussion
> else:
> content.allow_discussion = int(allowDiscussion)
>
>
>I get "KeyError: allow_discussion" from the del statement.
>Does hasattr() use aquisition and del does not?
Indeed.
Moreover, "hasattr" looks for class variables, too.
>Perhaps this is a bug?
Probably.
You can try to replace "hasattr(content, 'allow_discussion')"
by "content.__dict__.has_key('allow_discussion')".
This expects the "DiscussionTool" to carefully avoid
acquiring "allow_discussion").
--
Dieter
More information about the Zope-CMF
mailing list