[ZODB-Dev] Replacing bobobase_modification_time

Jim Fulton jim@zope.com
Tue, 08 Jan 2002 09:15:04 -0500


Casey Duncan wrote:
> 
> I am posting this here to get reactions here for something that we have been
> discussing on zope-dev that pertains to the ZODB.
> 
> Dieter M. discovered that bobobase_modification_time (henceforth referred to
> as b_m_t) is not always an accurate representation of an object's
> modification time, especially when an object has been modified in a
> transaction that has not been commited. This is a problem when doing things
> like cataloging an object in the same transaction that it is modified.
> 
> I thought this issue created an opprotunity to solve two problems. The above
> problem and the anachronistic b_m_t API itself, which is always good for a
> laugh in Zope classes. The idea is to create a new method in PersistentExtra
> "getModificationTime" which returns the actual modification time of an object
> based on the time the change is registered if it has been changed and not
> commited and then the last commit time if no change has been made. I also
> propose we add a second method "getLastCommitTime" or some-such which behaves
> the same as the current b_m_t method. At the same time we would deprecate
> b_m_t.
> 
> Kapil Thangavelu prototyped a couple of ideas. I think his latest code is
> simple and straighforward enough to be incorporated, although it does not yet
> replace and deprecate b_m_t, which I think is important.
> 
> He posted sample code to zope-dev yesterday, here is a (rather long) link:
> http://zope.nipltd.com/public/lists/dev-archive.nsf/0a8715d5f3c7b6a3802568c1006328f7/9dcad434e2a73f2680256b3a006abc37?OpenDocument
> 
> Thoughts anyone?

The basic problem is that b_m_t is a database modification time, not
an application-meaningful time. You pointed out that there are 
application-meaningful times that are not captured by the database time.
In addition, there are database modifications that are not meaningful
to the application.  Operations like export/import (copy/paste), 
version commit/abort, transactional undo, etc. cause the database times
to change without making application-meaningful changes.

Also, there could be state changes in an object that are not meaningful
to the application.

I think that a much better approach, if modification time is important
to your application, is to store the application modification time in the
object as a data attribute.

Jim

--
Jim Fulton           mailto:jim@zope.com       Python Powered!        
CTO                  (888) 344-4332            http://www.python.org  
Zope Corporation     http://www.zope.com       http://www.zope.org