[Zope] How to set an object's last modification time

2005-08-09 Thread Gabriel Genellina

Hello

I want to set an object's last modification time to match a certain date.
I see that this comes from the _p_mtime attribute and in cPersistence.c it 
is derived from _p_serial.

But when I try to set explicitely _p_serial, there is a ConflictError:
ZODB.POSException.ConflictError: database conflict error (oid 0x104a, 
serial this txn started with 0x035cfc63 2005-05-01 10:11:12.00, 
serial currently committed 0x035f10fe1d242e66 2005-08-03 02:38:06.83)


Writting _p_serial used to work fine at least until Zope 2.6.x 
(http://mail.zope.org/pipermail/zope-dev/2000-March/004020.html)

Now I'm using Zope 2.7.7.

Maybe I should not be playing with _p_serial, 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).


This is a test script:

import Zope
from Acquisition import aq_base
from ZODB.TimeStamp import TimeStamp
from OFS.Folder import Folder
from DateTime import DateTime

Zope.configure('..\etc\zope.conf')
root = Zope.app()
# create a test folder, if it does not exist
if not 'test' in root.objectIds():
print 'Creating test folder'
test = Folder(id='test')
root._setObject('test',Folder(id='test'))
get_transaction().commit()
# I want to change its last-modification-time
target = aq_base(root.test)
print 'Test folder: %s _p_serial=%s _p_mtime=%s b_m_t=%s' % (target.id, 
target._p_serial, DateTime(target._p_mtime), 
target.bobobase_modification_time())

ts = TimeStamp(2005,5,1,10,11,12) # a sample timestamp
target._p_serial = repr(ts)
target._p_changed = 1
get_transaction().commit()
print 'target._p_serial modified OK'
print 'Test folder: %s _p_serial=%s _p_mtime=%s b_m_t=%s' % (target.id, 
target._p_serial, DateTime(target._p_mtime), 
target.bobobase_modification_time())


#output:
#Test folder: test _p_serial=_รพ$.f _p_mtime=2005/08/02 23:38:06.830 GMT-3 
b_m_t=2005/08/02 23:38:06.830 GMT-3

#Traceback (most recent call last):
#  File C:\Prog\Zope\Questor\bin\testserial.py, line 22, in ?
#get_transaction().commit()
#  File C:\Prog\Zope\ZopeServer\lib\python\ZODB\Transaction.py, line 241, 
in commit

#ncommitted += self._commit_objects(objects)
#  File C:\Prog\Zope\ZopeServer\lib\python\ZODB\Transaction.py, line 356, 
in _commit_objects

#jar.commit(o, self)
#  File C:\Prog\Zope\ZopeServer\lib\python\ZODB\Connection.py, line 454, 
in commit

#s=dbstore(oid,serial,p,version,transaction)
#  File C:\Prog\Zope\ZopeServer\lib\python\ZODB\FileStorage.py, line 782, 
in store

#serials=(oserial, serial))
#ZODB.POSException.ConflictError: database conflict error (oid 0x104a, 
serial this txn started with 0x035cfc63 2005-05-01 10:11:12.00, 
serial currently committed 0x035f10fe1d242e66 2005-08-03 02:38:06.83)



Gabriel Genellina
Softlab SRL 


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] How to set an object's last modification time

2005-08-09 Thread Jens Vagelpohl


On 9 Aug 2005, at 04:14, Gabriel Genellina wrote:


Maybe I should not be playing with _p_serial, 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.


jens

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] How to set an object's last modification time

2005-08-09 Thread Paul Winkler
 On 9 Aug 2005, at 04:14, Gabriel Genellina 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.

What Jens said.

-PW


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )