[Zope-dev] KeywordIndex and PersistentList (Bug?)

Chris McDonough chrism@zope.com
25 Nov 2002 14:06:38 -0500


There is a workaround for this in the DocumentTemplate package.  It
implements a "safe_callable" function that seems to do the right thing
with ext class instances:

def safe_callable(ob):
    # Works with ExtensionClasses and Acquisition.
    if hasattr(ob, '__class__'):
        if hasattr(ob, '__call__'):
            return 1
        else:
            return type(ob) in ClassTypes
    else:
        return callable(ob)


On Mon, 2002-11-25 at 13:01, Jeremy Hylton wrote:
> It must be any instance of an ExtensionClass.  I think Python
> instances used to be true-for-callable as well, but that must have
> been fixed.
> 
> Python 2.1.3 (#5, Aug 15 2002, 10:41:31) 
> [GCC 2.95.3 19991030 (prerelease)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> from ZODB.PersistentList import *
> >>> callable(PersistentList())
> 1
> 
> Jeremy
> 
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )