[Zope-DB] Newbie - Z Search Interface, ZPT and nulls problem

Jakub Wisniowski jakub.wisniowski@euro.coig.pl
Sat, 9 Nov 2002 23:48:06 +0100


----- Original Message -----
From: "Dieter Maurer" <dieter@handshake.de>
To: "Jakub Wisniowski" <jakub.wisniowski@euro.coig.pl>
Cc: <zope-db@zope.org>
Sent: Friday, November 08, 2002 11:27 PM
Subject: Re: [Zope-DB] Newbie - Z Search Interface, ZPT and nulls problem


> Jakub Wisniowski writes:
>  > ...
>  >   <div tal:repeat="result batch">
>  >
>  >          <tr>
>  >           <td>
>  >              <span tal:replace="result/Symbol">Symbol goes here</span>
>  >           </td>
>  >           ...
>  >
>  >   When 'result/Symbol' is 'null' then I have no value in <td></td>
tags.
>  >   It's ok,
> It is how it should by.
>
> Try:
>
>       <span tal:replace="python: result.Symbol or 'null'">...</span>
>
> or (better)
>       <span
>         tal:define="sy result/Symbol | nothing"
> tal:replace="sy is None and 'null' or sy">
> ...
>               </span>
>
>
> Dieter

Note: there should be: tal:replace="python:sy is None and 'null' or sy">

Thank you. Nice piece of code, but I must say that it doesn't work. Problem
is that I can't use alternative like: result/Symbol | nothing. Even if
'Symbol' field in my database is 'null' 'result/Symbol' in my ZPT will have
logical value of true!

Charlie Clark has proposed to me:

    <span tal:define="symbol result/Symbol"> tal:content="python:
    test(same_type(result.Symbol, 1), 'int', 'not an int')">tests for an
integer</span>

It is something I'm looking for, but I need data type neutral solution like
(unfortunately this is not workable, because symbol is not of None type):
    <span tal:define="symbol result/Symbol"> tal:content="python:
    test(same_type(result.Symbol, None), 'null', 'not null')">tests for a
null</span>

Currently I still use my dirty 'isNull' python script... Any more
sugestions?

Jakub Wisniowski