[Zope] Can't add "date" property to new ZClass
Michel Pelletier
michel@digicool.com
Mon, 11 Oct 1999 18:14:48 -0400
Loren Stafford wrote:
>
> I'm creating a brand new ZClass (called "PDFClass"). It's my first ZClass.
> I've just added the Common Instance Property Sheet (called "PDFProperties").
> Now I'm trying to add properties to that property sheet. I added one
> "string" property OK, but now when I add the "date" property "pub_date", I
> get this error:
>
> Zope Error
> Zope has encountered an error while publishing this resource.
> Invalid Date-Time String
> Sorry, a Zope error occurred.
>
> Traceback (innermost last):
> File /opt/Zope-2.0.0/lib/python/ZPublisher/Publish.py, line 214, in
> publish_module
> File /opt/Zope-2.0.0/lib/python/ZPublisher/Publish.py, line 179, in
> publish
> File /opt/Zope-2.0.0/lib/python/Zope/__init__.py, line 201, in
> zpublisher_exception_hook
> (Object: PDFProperties)
> File /opt/Zope-2.0.0/lib/python/ZPublisher/Publish.py, line 165, in
> publish
> File /opt/Zope-2.0.0/lib/python/ZPublisher/mapply.py, line 160, in mapply
> (Object: manage_addProperty)
> File /opt/Zope-2.0.0/lib/python/ZPublisher/Publish.py, line 102, in
> call_object
> (Object: manage_addProperty)
> File /opt/Zope-2.0.0/lib/python/OFS/PropertySheets.py, line 403, in
> manage_addProperty
> (Object: PDFProperties)
> File /opt/Zope-2.0.0/lib/python/ZPublisher/Converters.py, line 157, in
> field2date
> File /opt/Zope-2.0.0/lib/python/DateTime/DateTime.py, line 499, in
> __init__
> Invalid Date-Time String: Sorry, an error occurred
>
> Of course, the value is invalid -- I didn't put any value in the "Value"
> box, because this is a class property, and values only make sense when the
> class is instantiated, right?
>
> Is this Zope's problem or mine?
Zope's. It should be a little smarter than that. In fact, it should be
smarter for instances also and just assume a sane value (like calling
DateTime() with no arguments, which returns 'now').
Please submit to the Collector. Should be a pretty trivial fix if you
want to take a hack at it and submit a patch, just sniff for a null
value and insert DateTime() instead of DateTime(formvalue).
-Michel