[Zope-Coders] ZCTextIndex too sensitive

Steve Alexander steve@cat-box.net
Thu, 12 Jun 2003 21:13:25 +0300


> I might suggest using safe_callable, except it would add a dependency to 
> DocumentTemplate, which feels very wrong to me. The try/except is also wrong 
> because you don't know if the exception was the result of calling the thing 
> (in which case it should propagate) or a result of it not being callable 
> (which usually raises TypeError AFAIK)

But this should be ok:

if callable(text):
     try:
         text.__call__
     except AttributeError:
         pass
     else:
         text = text()

--
Steve Alexander