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

Jakub Wisniowski =?ISO-8859-1?B?SmFrdWIgV2mcbmlvd3NraQ==?= <jakub.wisniowski@euro.coig.pl>
Fri, 8 Nov 2002 14:36:43 +0100

  Hi all

  I have been using Zope for a week but now I have a really big problem, I was not able
  to find solution for neither in the web nor in this list archives
  (although similar problems appeared).

  Actually I work with Sybase database and my
  problem concerns showing results of select query. I have a ZSQL Method
  with a very simple select statement - sort of SELECT * FROM table. I
  have generated a report for it using Z Search Interface. But I don't use DTML
  so my generated report is based on ZPT. Problem arises when there is
  any null value. Sample fragment of my code:

 <body tal:define="results here/SQL/showDatabaseTable;
                   size python:int(path('request/size | nothing') or 50);
                                       start request/start|python:0;
                   batch python:modules['ZTUtils'].Batch(results,
                   previous python:batch.previous;
                   next python:batch.next">
  <div tal:repeat="result batch">
             <span tal:replace="result/Symbol">Symbol goes here</span>

  When 'result/Symbol' is 'null' then I have no value in <td></td> tags.
  It's ok, but I'm not able to determine if 'result/Symbol' is 'null'! I have tried comparison
  with 'nothing', python's 'None' and with '' (empty String) - it doesn't
  work. Only with the last one I can discover that value of type
  String is empty/null. But what with other data types? Is it possible
  to check for null values???

  At last - I must say that I have written Python script that deals
  with nulls but although it works I don't think that it is a good
  solution. Here is my script:

            #script name: isNull
            #parameters param
            if repr(param) == 'Missing.Value':
               return 1
            elif param == '':
               return 1
            return 0

  (for 'null' values it returns 1)
  I use it with:
      <span tal:condition="python:here.isNull(result.Symbol)">empty</span>

  Any sugestions?
  (Earlier I've posted a message about problem with Sybase's bigint
  which seems to be incorrectly casted by Zope to integer. I've partially solved
  this using SQL casting to String.)

 Jakub Wisniowski