Re: notifyModified called when object re-indexed

Dieter Maurer <[email protected]> Wed, 14 Jun 2006 21:52:09 +0200
Newsgroups gmane.comp.web.zope.plone.archetypes.devel
Message-ID <[email protected]>
Roché Compaan wrote at 2006-6-13 17:03 +0200:
>Can somebody explain why notifyModified is called from CatalogMultiplex
>when re-indexing an object only if idxs is an empty list?
>
>Here's the relevant code:
>
>    def reindexObject(self, idxs=[]):
>        if idxs == []:
>            if hasattr(aq_base(self), 'notifyModified'):
>                self.notifyModified()

I think it is an abuse of "reindexObject"...
But, I can report about the motivation:

   When you edit an object, you often want to change the
   modification time (done by "notifyModified").

   Because there are many "edit" method implementations,
   the implementor (who introduced the hack above) tried
   to avoid modifying all of them. Therefore, he looked
   for a single place where to possibly change the modification time.
   He came up with "reindexObject", called by all "edit" methods...

   Now, "reindexObject" is often called for specific indexes
   when you do *NOT* want to change the modification time, e.g.
   after a workflow change (which does not modify the object itself
   but some kind of metadata only).
   Therefore, the implementor decided to let "reindexObject"
   call "notifyModified" when no indexes are specified (as
   used by the "edit" methods) but not, if indexes are specified.

As mentioned above, I do not like this solution. But, we may need to
live with it.

The implementation was originally introduced in CMF (and probably
copied over to AT).



-- 
Dieter