[Zope-Coders] Re: Catalog.py

Andreas Jung andreas@andreas-jung.com
Tue, 04 Feb 2003 17:19:15 +0100


This is fixed by the following:

# Collector #771: provide a safe_callable() method with a
# fallback (when ZCatalog might be used outside Zope)

try:
    from DocumentTemplate.cDocumentTemplate import safe_callable
except:

    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)

I can not see anything wrong with this code?

Andreas

--On Dienstag, 4. Februar 2003 10:41 -0500 Chris McDonough 
<chrism@zope.com> wrote:

> The safe_callable function provided as a "backup" if the one imported
> from cDocumentTemplate fails is broken.  It makes references to a
> ClassTypes variable that is not initialized.
>
> Andreas, can you fix this?
>
> - C
>
>
>




    ---------------------------------------------------------------------
   -    Andreas Jung                     http://www.andreas-jung.com   -
  -   EMail: andreas at andreas-jung.com                              -
   -            "Life is too short to (re)write parsers"               -
    ---------------------------------------------------------------------