[Zope-dev] Converters.field2date, allow empty string to return None?

Brad Clements bkc@murkworks.com
Fri, 1 Sep 2000 16:05:35 -0400


One thing that has been bothering me is that I can't easily test my 
ZSQL Methods if they accept a date type unless I completely fill all the 
date arg types.

For example, if the sqlmethod has argument type 
  startdate:date=''


and in the body I have
 <dtml-if startdate> ...

When i use the test form, I can't leave the date field empty, otherwise I 
get a conversion error from Converters.field2date()

I also have this problem with any form that has type date, if the end-user 
doesn't put a date in the form, I get a conversion error.

Its okay with me to receive an empty string, which gets converted to 
None .. I just put NULL in the sql database.

So .. what's the correct fix to allow empty fields to return either '' or 
None from field2date?

I can alter Converters.py...

I see that converters required: exists, but does that imply that all other 
converters allow an empty string to return None? Or do we need to add 
an explicit "optional" type?

Either way, I'd like to fix this, but what's the best way?


Brad Clements,                bkc@murkworks.com   (315)268-1000
http://www.murkworks.com                          (315)268-9812 Fax
netmeeting: ils://ils.murkworks.com               AOL-IM: BKClements