[Zope-CMF] Bug in PortalContent

Tres Seaver tseaver@palladion.com
Sun, 03 Jun 2001 22:35:39 -0400


seb bacon wrote:

> Just a little one...
> Here's the fix:
> 
> 
> Index: PortalContent.py
> ===================================================================
> RCS file: /cvs-repository/CMF/CMFCore/PortalContent.py,v
> retrieving revision 1.16
> diff -c -r1.16 PortalContent.py
> *** PortalContent.py	2001/06/01 18:43:33	1.16
> --- PortalContent.py	2001/06/03 17:13:40
> ***************
> *** 250,255 ****
> --- 250,256 ----
>           right now, I will return that. Should be replaced with
>           a list of tuples for every opaque item!
>           """
> +         talkback = None
>           if hasattr( aq_base( self ), 'talkback' ):
>               talkback = self.talkback
>           if talkback is not None:


Thanks for pointing this out!  I've tweaked it to use the
three-argument form of getattr, which feels a bit tighter
(I also made the returned value a tuple when returning nothing):

--- CMFCore/PortalContent.py	2001/06/01 18:43:33	1.16
+++ CMFCore/PortalContent.py	2001/06/04 02:55:44
@@ -250,11 +250,10 @@
          right now, I will return that. Should be replaced with
          a list of tuples for every opaque item!
          """
-        if hasattr( aq_base( self ), 'talkback' ):
-            talkback = self.talkback
+        talkback = getattr( aq_base( self ), 'talkback', None ):
          if talkback is not None:
              return ((talkback.id, talkback),)
          else:
-            return []
+            return ()

  InitializeClass(PortalContent)

Again, thanks much;  I've checked this in.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@digicool.com
Digital Creations     "Zope Dealers"       http://www.zope.org