[Zope] hasattr in tal:condition

Chris Withers lists at simplistix.co.uk
Tue Mar 16 04:20:51 EST 2004


Andre Meyer wrote:

>    <span tal:condition="python:test(hasattr(request, results), 1, 
> 0)">span</span>

using hasattr in any Zope-ish python is BAD, since it ignores all exceptions, 
including things like ConflictErrors, which you NEVER want to catch...

> PS in the full version the statement looks as follows:
> 
>    <body tal:define="results python:test(hasattr(request, results), 
> request.results, here.Catalog()); ... >

<body tal:define="results getattr(request,'results',here.Catalog()); ... >

cheers,

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk




More information about the Zope mailing list