[Grok-dev] Re: applyChanges and add forms
Philipp von Weitershausen
philipp at weitershausen.de
Sun Apr 15 05:45:31 EDT 2007
Martijn Faassen wrote:
> Philipp did a refactoring of the form structure a while ago, and one of
> the things he did was make applyChanges useable in add forms. But I ran
> into a snag that might give us insight in what applyChanges should
> really be doing for us in the context of grok.AddForm.
> This is because applyChanges in formlib tries to retrieve the data from
> the content object before it saves. This is to determine whether to
> actually change the field at all, and to set a 'changed' flag that's
> returned - if the underlying content object already has these values, no
> changes happen and nothing needs to be done.
> This is nice in case of edit forms, but it blocks this usage of
> AddForms. Of course, in fact I lied in the above code. I claimed that
> MyContent implements the schema IMyContent but I do no such thing. I
> intuitively expected applyChanges help me make sure that this happened,
> but perhaps this is not the right pattern.
I too would expect applyChange to help me here.
> What can be do to make schema-driven content even simpler in Grok?
> Having to do a special __init__ and typing all the fields again seems a
> bother I'd like to avoid.
I agree. I'd say we want to enhance Zope's applyChanges to not expect
the field value on the object. At least that's the most straight-forward
thing I can think of -- and it would go along with what I expect from
http://worldcookery.com -- Professional Zope documentation and training
More information about the Grok-dev