Maurits van Rees-3 wrote:
> 
> Martin Aspeli, on 2007-04-03:
>> Having an "oldObject" doesn't make sense, because that's not how objects
>> are
>> updated. The event is per-object, not per-field, and we don't update
>> objects
>> by making a copy of the entire object and then changing values, we just
>> change fields directly.
> 
> Well, something like that seems to happen with other events.  The
> event handler I have for updating that total when an object is added
> is subscribed to IObjectMovedEvent.  This includes IObjectAddedEvent
> and IObjectRemovedEvent as they inherit from it.
> 

That's fundamentally different, though. It's easy to know the old/new parent
and old/new name, since they are external to the object. The code that
moves/adds/removes the object (in OFS.ObjectManager) knows where the object
came from and where it went to.

IObjectModified is emitted at various points from view-level code, e.g.
processForm() in Archetypes (I think). It could possibly keep track of
old/new values, but it'd be tricky and possibly difficult to ensure it
stayed accurate. There is no such things as the "old object" because there's
only ever one object that gets changed.



> That event is fired two times before you get to the edit form in your
> browser (with portal factory) and three times afterwards.  In the
> fourth event a content type with default values is added at the folder
> where it is supposed to be added.  In the last event that content type
> has been given its proper values and is now moved from that folder
> to... that same folder!
> 

This is basically because of the premature object creation in CMF/AT,
portal_factory, and the title-to-id renaming scheme. Note that for
Archetypes, you may find it useful to listen to IObjectInitializedEvent
(first proper save) and IObjectEditedEvent (subsequent edits). Both derive
from IObjectModified, but should be fired only once. In fact, if you listen
for IObjectModifiedEvent, you're probably getting those as well. :)

Martin

-- 
View this message in context: 
http://www.nabble.com/IObjectModifiedEvent%3A-can-you-know-the-previous-values--tf3516657.html#a9834394
Sent from the Plone Product Developers mailing list archive at Nabble.com.


_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to