[Zope-dev] RFC: Date property requiers valid date (no more)
Johan Carlsson
johanc@torped.se
Wed, 3 Oct 2001 17:06:24 +0200
Hi,
We currently want to use date-properties in the regular property sheet.
The current date-property doesn't accept an empty value.
We want to be able to submit an empty string and set a NullDate value
indicating. Also a NullDate value should return an empty string when the
"manage_propertiesForm" is rendered, e.g. showing an empty field.
We have currently chosen a empty string "", to represent the NullDate value.
(We haven't found any NullDate representation in DateTime and have concluded
that it doesn't exist?)
Choosing None as the NullDate value would have been preferred but it
generates
issues with the rendering of "manage_propertiesForm".
Question:
Is there anything better then an empty string for the NullDate value?
Best Regards,
Johan Carlsson
www.torped.se
[Here's our hot-patch]
from ZPublisher import Converters
def fixedfield2date(v):
print "Fixed field2date conversion", fixedfield2date, v
from DateTime import DateTime
if hasattr(v,'read'): v=v.read()
else: v=str(v)
if v=='':
return v
return DateTime(v)
Converters.field2date = fixedfield2date
Converters.type_converters['date'] = fixedfield2date
print "ZPublisher.Converters.field2date patched."