[Grok-dev] Heads up: Renamed applyChanges to applyData
Philipp von Weitershausen
philipp at weitershausen.de
Tue Apr 17 13:35:11 EDT 2007
After discussing some issues concerning applyChanges with Martijn [1], I
have now renamed applyChanges to applyData and fixed some of its
behaviour outside EditForms.
From the checkin message:
* applyData no longer calls zope.formlib.form.applyChanges, it uses a
helper in grok.formlib that *optionally* supports "update mode"
(setting form data on an object only when the data needs to be
updated). Update mode is disabled on normal forms, but it is enabled
on EditForms.
This was the main motivation for this refactoring (see mailinglist
thread above).
* applyData continues to send IObjectModifiedEvents. It does that now
by employing another helper in grok.formlib. The event that's sent
carries all the necessary information that's required by the event
spec (which field of which schema was changed).
* applyData no longer returns a simple boolean to indicate whether
changes had to be made to an object. It now returns a dictionary
that contains the information *which* fields of which interfaces had
to be changed (interfaces are the keys of the dict, a list of
attributes are the values).
If no changes are made to the object, an empty dict is returned.
Given Python's semantics for booleans, this is still compatible with
the old return value of applyChanges. For example, you can still
do::
if self.applyData(...):
print 'Changes were made'
Backwards compatibility for applyChanges was provided for 1 month.
[1] http://mail.zope.org/pipermail/grok-dev/2007-April/000638.html
--
http://worldcookery.com -- Professional Zope documentation and training
More information about the Grok-dev
mailing list