ObjectWidget itself seems to be fine, but we discovered a fundamental problem in z3c.form.
The meat is that widget value * validation * extraction * applying values need to be separated and made recursive-aware.
An example:
> The situation is the following: > - schema is like this: > class IMySubObject(zope.interface.Interface): > foofield = zope.schema.Int( > title=u”My foo field”, > default=1111, > max=9999) > barfield = zope.schema.Int( > title=u”My dear bar”, > default=2222, > required=False) > class IMyObject(zope.interface.Interface): > subobject = zope.schema.Object(title=u’my object’, > schema=IMySubObject) > name = zope.schema.TextLine(title=u’name’) > > - on object editing > - we need to keep the (old) (IMySubObject) object in place > – do not create a new one > - value setting is done in the editform handleApply > - extractData, extract needs to extract recursively > - return assignable values > - it has no idea about subobjects > - let’s say the IMySubObject data is validated OK, but there’s an > error in IMyObject (with name) > - now the problem is: > - IMyObject.subobject extract gets called first > it sets the values on the existing object (and fires > ObjectModifiedEvent) > - IMyObject.name detects the error > it does not set the value > BUT IMyObject.subobject sticks to the extracted value that should be > discarded, because the whole form did not validate?!?!?!