[Zope] Basic Template question : 'truthiness'

David H bluepaul at earthlink.net
Sun Jun 11 16:46:48 EDT 2006


David H wrote:

> Mark Gibson wrote:
>
>> 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
>> _______________________________________________
>> Zope maillist  -  Zope at zope.org
>> http://mail.zope.org/mailman/listinfo/zope
>> **   No cross posts or HTML encoding!  **
>> (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
>> http://mail.zope.org/mailman/listinfo/zope-dev )
>>
>> __________ NOD32 1.1592 (20060611) Information __________
>>
>> This message was checked by NOD32 antivirus system.
>> http://www.eset.com
>>
>>
>>
> Mark,
> Just looking at your second example:
> <-- This doesn't evaluate to true -->
> <div tal:condition="results | request/dosearch | request/querytype | 
> nothing">THIS DOESN'T SHOW UP</div>
>
> If you replace '| nothing' with '| default' you will get "THIS DOESNT 
> SHOW UP"
>
> David
>
>
Mark,

Sorry  I misread your problem.  My last post!  *Sorry* :-)

David



More information about the Zope mailing list