[Zope] How to set an object's last modification time
Gabriel Genellina
gagenellina at softlab.com.ar
Wed Aug 10 21:53:22 EDT 2005
At Tuesday 9/8/2005 16:25, Paul Winkler wrote:
> >> Maybe I should not be playing with _p_serial,
>
>Correct, you should not be. All _p_ attributes are reserved
>for use by the ZODB and applications should never mess with them.
>
> >> but how can I set the
> >> object's last modification time? I want it to be in sync with an
> >> external representation (stored in CVS).
> >
> > Set your very own attribute on the object that holds the modification
> > time, and modify it at will.
But I need to track the modification time of *all* objects (folders, zpt,
python scripts, instances of third-party installed products...).
I go back and forth from FileStorage to a filesystem representation (using
APE) which is under CVS control.
Fortunately I've found a way to successfully modify _p_serial: just ignore
the (fictitious) conflict. In fact, there is no real conflict since no data
has been modified (and no other thread is running), just the timestamp was
changed.
def ignoreConflict(self, oid, committedSerial, oldSerial, newpickle,
committedData=''):
self._serial = oldSerial
return newpickle
from ZODB.FileStorage import FileStorage
FileStorage.tryToResolveConflict = ignoreConflict
Of course this script is run offline, with a single user accessing the
database, and it works for this specific situation because I know there is
no real conflict.
Gabriel Genellina
Softlab SRL
More information about the Zope
mailing list