[Zope-dev] Re: [Zope] [Bug] "bobobase_modification_time" unreliable to catalog

kapil thangavelu k_vertigo@yahoo.com
Mon, 7 Jan 2002 04:38:10 -0800


On Monday 07 January 2002 06:20 am, Casey Duncan wrote:
> On Saturday 05 January 2002 08:15 pm, kapil thangavelu allegedly wrote:
> > On Sunday 30 December 2001 08:00 pm, Casey Duncan wrote:
> > > This behavior is logical if unintuitive. I propose
> > > that we can kill two birds with one stone to fix this:
> > >
> > >  - Add a new method perhaps: getModificationTime() to
> > > the API of SimpleItem or even Persistent that returns
> > > the ZODB modification time or if the object has been
> > > changed, but not yet commited, the current date/time.
> > >
> > > - Deprecate bobobase_mod_time and perhaps even omit it
> > > entirely from Zope3.
> > >
> > > This will fix the aforementioned bug and get rid of an
> > > API anachronism.
> > >
> > > Thoughts?
> >
> > sounds good, i played around with an implementation to do the above. i'm
> > not posting it here causes its inefficient, although i'm happy to email
> > it to anyone who's interested. it basically added three methods.
>
> [snip details]
>
> For memory concerns, couldn't you just store the DateTime as a floating
> point number? This would incur just a small overhead to create a DateTime
> object when the value is looked up.
>
> I am interested in seeing this code. From my perspective it seems overly
> sophisticated. I'm interested how you derive the registration time in the
> first place.

your right, what i did was overly complex. i took your suggestions and 
simplified to the following two methods, which stores the txn registration 
time on the object as a float. it looks like an ok solution, imo. it doesn't 
do much for newly created persistent objects for which it falls through to 
the behavior of bobobase_modification_time and returns the current time.

in PersistentUtil class in lib/python/App/PersistentExtra.py new method

from Acquisition import aq_base
def getModificationTime(self):
	ob = aq_base(self)
	if hasattr(ob, '_p_changed') and ob._p_changed:
		return DateTime(self._p_registration_time)
	else: return self.bobobase_modification_time()

in Transaction class in lib/python/ZODB/Transaction.py altered register method

def register(self, object):
	self._append(object)
	object._p_registration_time = time.time()


cheers

kapil