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

M.-A. Lemburg mal@lemburg.com
Wed, 27 Nov 2002 09:24:04 +0100


Jeff Kowalczyk wrote:
> I agree, mxODBC is reasonably licensed; I'm going to check out the Zope mxODBC DA, which I
> believe is still in beta at present.
> 
> In the meantime, I've been trying to research the mystery of 'Missing.Value', and how to
> work effectively with it as a None equivalent.

Note that the mxODBC Zope DA also maps None returns (which represent
NULLs in SQL) to Zope's Missing.MV. The Zope DA has to do this to
stay compatible to the other DAs.

Perhaps I should make this particular mapping an option in the DA ?!

> It seems that I should be able to use repr() to treat the Missing.Value as a string and
> compare it that way, or do a define and compare it to that instance. I have to watch it
> when moving tal: expressions out to python scripts; I already have an explosion of them
> that need to be culled and made more generic.

Since Missing.MV is a singleton just like None you should be able to
use the "is" comparison to test for it:

import Missing

if results[1].name is Missing.MV:
    print 'Name not given'

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/