[Zope-CMF] Re: Don't always set the modification date?

Paul Winkler pw_lists at slinkp.com
Wed Feb 16 13:57:07 EST 2005


On Wed, Feb 16, 2005 at 03:53:38PM +0100, Florent Guillaume wrote:
> Paul Winkler  <pw_lists at slinkp.com> wrote:
> > Are the reasons anything other than historical?
> > That feels wrong. Would changing it break any known applications?
> 
> Yes.
> Historically the modification date was returned using just
> bobobase_modification_date. Obviously we wanted something more flexible
> so I added an explicit modification_date attribute. But it had to be
> updated, and there are hundreds of products out there that we didn't
> want to change, so I piggybacked on reindexObject and decided to call
> notifyModified() when a simple reindexObject() without arguments was
> called. That fits the bill pretty well.

I see. I had noticed that reindexObject() is the closest we have to an
existing "this object changed" hook, I have been guilty of 
monkey-patching it at times.

> > > Calling 
> > > reindexObject(idxs=['modified']) preserves the timestamp and updates the 
> > > index,
> 
> That's the better way to do it I think.

hmm, i may want to update other indexes as well,
but I can easily add them to the list.
 
> > but doesn't update the brain / metadata in the catalog.
> 
> That one is really a bug in ZCatalog. :-( I can't find a report about
> it, but I thought I saw patches floating around to fix this.

Are you sure ZCatalog still behaves that way? 
I don't have time to explore much at the moment but glancing
at the code, it looks like the intent is for the metadata to
be updated.

>From ZCatalog.py in a Zope 2.7.3 installation:

    def catalog_object(self, obj, uid=None, idxs=None, update_metadata=1):
                                                       ^^^^^^^^^^^^^^^^^

... and from CatalogTool in CMFCore 1.4.3:

    def catalog_object(self, object, uid, idxs=[]):
        ...
        ZCatalog.catalog_object(self, w, uid, idxs)

    ...
    def reindexObject(self, object, idxs=[]):
        ...
        self.catalog_object(object, url, idxs=idxs)


AFAICT, the only time that updating metadata is suppressed
is in ZCatalog.reindexIndex().

I'll test this later and see if my reading is correct.
 
> > > Occasionally I use this workaround:
> > > 
> > >     obj.reindexObject(idxs=['suppress_notifyModified'])
> 
> That's a working workaround yes.

let me see if i'm following this - so, you're relying on
the fact that CMFCatalogAware.reindexObject() doesn't check
the validity of index names, and only calls notifyModified()
if the index list is empty? (I don't get why it does that
anyway. What's reason for wanting different behavior when
you pass specific indexes?)

At first I wondered why this workaround was described as "expensive"
- then I realized it's the difference between updating all indexes vs.
updating only the 'modified' index. As far as that goes, there
are times I might want to do either one.

Thanks much for the tips, guys!

 
> > > 5.) If CMFEvent will become reality cleaning up that mess should be 
> > >     easier.

Some googling suggests that these would be based
on Products/Event and Products/EventListenerTool from cvs.zope.org -
yes? no?


-- 

Paul Winkler
http://www.slinkp.com


More information about the Zope-CMF mailing list