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


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?


Attachment: signature.asc
Description: This is a digitally signed message part

For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to