Philipp von Weitershausen wrote:
Michael Kerrin wrote:
Log message for revision 72694:
Emit an ObjectModifiedEvent on successfully modifying a property with the proppatch method.

+ if changed:
+            zope.event.notify(ObjectModifiedEvent(self.context))

Just emitting an ObjectModifiedEvent like that is pretty useless, IMO. With this you have no clue

- whether the object or the object's annotations were modified

- which properties of which schema were modified.

The good news is that the ObjectModifiedEvent API actually supports this kind of stuff, you just need to use it:

  info = Attributes(ITheSchema, 'foo', 'bar', 'blergh')
  notify(ObjectModifiedEvent(obj, info))

(Attributes is importable from zope.lifecycleevent). Note that the object must not necessarily provide ITheSchema, it could also be that the ITheSchema(obj) adapter was changed (this is useful when sending modified events for annotation adapters like IZopeDublinCore).

Very interesting - I never even knew you could do this :-)

All modifications made by the PROPPATCH will be done via the adapter lookup you just mentioned so it is really nice that this is supported.
Unfortunately, not many places in Zope 3 itself are good examples of this. In fact, not even formlib sends this extra information along with the events, something I've been meaning to report and fix. (Thanks for reminding me to do so :)).
Thanks for the tip, I will definitely update webdav to use it.

Zope3-dev mailing list

Reply via email to