[Zope] Basic Template question : 'truthiness'

Mark Gibson mark at dimensional.com
Sun Jun 11 15:35:40 EDT 2006


I thought I knew how this stuff worked, but this has gotten me banging 
my head against a wall.

I'm trying to evaluate a condition expression, and I'm not getting what 
I expect when using path, and I get a different result when using 
python.  The following expressions

results=<span tal:content="results" /><br />
dosearch=<span tal:content="request/dosearch | string:NO SEARCH" /><br />
querytpe=<span tal:content="request/querytype | string:NO QUERYTYPE" 
/><br />

<!-- test with python: this gives me what I expect -->
<div tal:condition="python:len(results) or request.get('dosearch',None) 
or request.get('querytype',None)">TRUE IN PYTHON</div>

<-- This doesn't evaluate to true -->
<div tal:condition="results | request/dosearch | request/querytype | 
nothing">THIS DOESN'T SHOW UP</div>

----
Produces:
results=[]
dosearch=NO SEARCH
querytpe=mps
TRUE IN PYTHON


As you can see, the second expression doesn't evaluate to True.  Can 
someone explain the subtleties I seem to be missing?

Thanks,
Mark


More information about the Zope mailing list