Z3c.form.object - Date conversion error

Following-up on my thread Wrong Widget/Field conversion in datagrid while simplifying my question to: what causes this traceback?

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 167, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 376, in publish_module
  Module ZPublisher.WSGIPublisher, line 271, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 68, in call_object
  Module pnz.erpediem.core.browser.remadv, line 48, in __call__
  Module plone.autoform.view, line 40, in __call__
  Module plone.autoform.view, line 62, in _update
  Module z3c.form.group, line 52, in update
  Module z3c.form.group, line 48, in updateWidgets
  Module z3c.form.field, line 274, in update
  Module z3c.form.browser.multi, line 63, in update
  Module z3c.form.browser.widget, line 171, in update
  Module z3c.form.widget, line 523, in update
  Module Products.CMFPlone.patches.z3c_form, line 46, in _wrapped
  Module z3c.form.widget, line 135, in update
  Module z3c.form.widget, line 518, in value
  Module collective.z3cform.datagridfield.datagridfield, line 149, in updateWidgets
  Module z3c.form.widget, line 460, in updateWidgets
  Module z3c.form.widget, line 401, in applyValue
  Module z3c.form.object, line 116, in toFieldValue
  Module plone.app.z3cform.converters, line 66, in toFieldValue
AttributeError: 'datetime.date' object has no attribute 'split'

I am attempting to display a date in a collective.z3cform.datagridfield. My object contains a date, z3c.form.object then fails, using <DateWidget 'invoic_in_date'> as the widget and <DateWidgetConverter converts from Date to DateWidget> as the converter when using plone.app.z3cform.converters.

Here, toFieldValue() expects a string and intends to return a date - which obviously fails...

I do not understand the innards of the DataGrid field well enough to find the cause of this issue. How to fix?

Also, the same type of error occurs with a schema.Choice field. Here plone.app.z3cform.converters expects the object converter to pass a list rather than a string. I have a <SelectWidget 'document_reference_type'> and z3c.form.object is using <SequenceDataConverter converts from Choice to SelectWidget>

Life is too short :wink:

I ended up monkeypatching ObjectConverter.toFieldValue() in z3c.form.object

                # pass the expected type for Date and Choice fields
                if isinstance(converter, DateWidgetConverter):
                    newvalRaw = str(newvalRaw)
                elif isinstance(converter, SequenceDataConverter):
                    newvalRaw = [newvalRaw,]
                newval = converter.toFieldValue(newvalRaw)

This is undoubtedly the wrong place for the patch, and will eventually blow up in my face - but at least that failure will be visible and give some hints as to where to dig deeper.

was this still an issue after using master branch of dartagridfield as mentioned here? schema.Date and schema.Datetime converter broken · Issue #133 · collective/collective.z3cform.datagridfield · GitHub

@petschki - yes, this is still an issue with the dev version.