[Zope-DB] Test for equality to Missing.Value (empty field)?

Charlie Clark charlie@begeistert.org
Mon, 25 Nov 2002 20:41:40 +0100


On 2002-11-25 at 17:46:26 [+0100], Jeff Kowalczyk wrote:
> How can I include the ZSQLMethod result's representation of an empty/null 
> field value in a two- or threeway equality test in python? My immediate 
> need is to check in a tal:condition that two fields are equal and yet not 
> null, on results returned from Win32 Zope 2.5.1 Win32 ODBC connection to 
> SQL Server 2000. Here's my test-harness element:
> 
> <span tal:condition="python:test
> (shipment.ChargeAsBilled==shipment.ChargeAsPaid)"
>   tal:content="python:repr(shipment.ChargeAsPaid)"
>   tal:attributes="style string:color=green"></span>

Sounds like a prime candidate for using a PythonScript. But I think it's 
possible in ZPT
<div tal:define="AsBilled shipment/ChargeAsBilled | nothing;
AsPaid shipment/ChargeAsPais | nothing">
<br tal:content="python: test(AsPaid and AsBilled and (AsPaid == AsBilled), 
AsPaid, 'Missing.Value')">
</div>

might give you what you're looking for but it's untested and I'm not quite 
sure where you're values are coming from.

Charlie