[ZODB-Dev] undo / non-undoable
Harm_Kirchhoff at mail.digital.co.jp
Harm_Kirchhoff at mail.digital.co.jp
Mon Feb 16 20:00:10 EST 2004
When I lost some data and tried to wheel my ZODB back to the state
before, I encountered that any transaction seemed to be undoable.
'UndoError: Undo error None: non-undoable transaction', no matter in
which order I tried to undo the last 5 transactions.
>From my research in the internet and mailing lists, I can not explain
this error. My understanding is, that if you try to wheel back,
transaction by transaction starting from the most recent, there should
generally not be a problem, because there can be no more recent
transactions which depend on the changes made, since each transaction I
undo is the most recent.
I isolated the problem in the attached code. Running this code produces
this output:
>>> reload(undo) ; test_undo1()
<module 'undo' from 'C:/Program Files/Zope262/Extensions\undo.py'>
[{'description': 'level 1.2.a created', 'user_name': '/ me', 'id':
'A1MSHccYcIg=', 'time': 1076818426.6630001}, {'description': 'level 1
created', 'user_name': '/ me', 'id': 'A1MSHccCmBE=', 'time':
1076818426.6429996}, {'description': 'initial database creation',
'user_name': '', 'id': 'A1MSHcbBDt0=', 'time': 1076818426.5829997}]
{'level1_b': {}, 'level1_a': {'sub_level1.2.a': '1.2.a'}}
True
>>> test_undo2()
{'level1_b': {}, 'level1_a': {'sub_level1.2.a': '1.2.a'}}
[{'description': 'level 1.2.a created', 'user_name': '/ me', 'id':
'A1MSHccYcIg=', 'time': 1076818426.6630001}, {'description': 'level 1
created', 'user_name': '/ me', 'id': 'A1MSHccCmBE=', 'time':
1076818426.6429996}, {'description': 'initial database creation',
'user_name': '', 'id': 'A1MSHcbBDt0=', 'time': 1076818426.5829997}]
willl try to undo: A1MSHccYcIg=
Traceback (most recent call last):
File "<pyshell#11>", line 1, in ?
test_undo2()
File "C:/Program Files/Zope262/Extensions/undo.py", line 39, in
test_undo2
storage.undo( log[0] ['id'] )
File "C:\PROGRA~1\Python23\Lib\site-packages\ZODB\BaseStorage.py",
line 221, in undo
raise POSException.UndoError, 'non-undoable transaction'
UndoError: Undo error None: non-undoable transaction
Code : =============================================================
import ZODB
from ZODB import FileStorage, DB
import pprint
def test_undo1():
root,connection,db,storage = open_zodb('C:/temp/test_zodb.fs')
try:
root['level1_a'] = {}
root['level1_b'] = {}
root._p_changed = 1
get_transaction().note('level 1 created') # a message for
the log
get_transaction().setUser('me') # the user, who
made the changes
get_transaction().commit()
root['level1_a'] = {'sub_level1.2.a' : '1.2.a'}
root._p_changed = 1
get_transaction().note('level 1.2.a created') # a message
for the log
get_transaction().setUser('me') # the user, who
made the changes
get_transaction().commit()
print storage.undoLog(0, 20)
print root
finally:
close_zodb( (root,connection,db,storage) )
return True
def test_undo2():
root,connection,db,storage = open_zodb('C:/temp/test_zodb.fs')
try:
print root
log = storage.undoLog(0, 20)
print log
print 'willl try to undo:',log[0] ['id']
storage.undo( log[0] ['id'] )
finally:
close_zodb( (root,connection,db,storage) )
return True
def open_zodb(Path):
"Open ZODB."
storage = FileStorage.FileStorage(Path)
db = DB(storage)
connection = db.open()
root = connection.root()
return (root,connection,db,storage)
def close_zodb(DataBase):
"Closes the ZODB."
DataBase[1].close()
DataBase[2].close()
DataBase[3].close()
return True
More information about the ZODB-Dev
mailing list