[ZODB-Dev] strange savepoint behavior
dvd
dvd at gnx.it
Thu Nov 3 07:10:57 EST 2005
Hi all,
I'm writing a framework on top of ZODB and I'm now investigate on a
strange savepoint-related behavior (after a savepoint.rollback the
attributes of a Persistent-derived class disappears)
While investigate i write this code and found another strange behavior
(maybe correlated?)
***** CODE *****
from ZODB import FileStorage, DB
from persistent import Persistent
from BTrees.OOBTree import OOBTree
import transaction
dbname = '/tmp/test.db'
fstorage = FileStorage.FileStorage(dbname)
db = DB(fstorage)
conn = db.open()
root = conn.root()
class Word(Persistent):
def __init__(self, word, id):
super(Word, self).__init__()
self.id = id
self._word = word
data = root['data'] = OOBTree()
commonWords = []
count = "0"
for x in ('hello', 'world', 'how', 'are', 'you'):
commonWords.append(Word(x, count))
count = str(int(count) + 1)
sv = transaction.savepoint()
for word in commonWords:
sv2 = transaction.savepoint()
data[word.id] = word
sv.rollback()
print commonWords[1].id
***** END CODE *****
if i run this snippet, the last line (print ...) raise a POSKeyError
It works nicely if i omit the "sv2 = transaction.savepoint()" line or if
the Word class is a subclass of object
Have you any idea?
david
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/zodb-dev/attachments/20051103/054ffcd5/attachment.bin
More information about the ZODB-Dev
mailing list