On Thu, 2005-11-03 at 09:44 -0500, Tim Peters wrote: > You didn't say which version of ZODB you're using, but I doubt it matters: > I was able to reproduce the POSKeyError in the current ZODB 3.6 branch.
I'm using ZODB 3.5.1 > > I expect it's an artificial glitch due to never committing anything (i.e., > an extreme case some part of the code just isn't expecting). If I add > > transaction.commit() > > right after your > > data = root['data'] = OOBTree() > > then the POSKeyError goes away, and I get > > Traceback (most recent call last): > File "pos_dvd.py", line 34, in ? > print commonWords.id > AttributeError: 'Word' object has no attribute 'id' > > instead. That makes sense to me: rolling back invalidates the in-memory > Word objects, and they lose all their user-defined attributes then. Since > the object states were never committed (except to savepoints that were > explicitly thrown away), there's no way to get the attributes back. great! this is exactly the error that i'm trying to reproduce so is this an expected behavior (the lost of the attributes)? this sounds a bit strange to me, let me explain: with: **** CODE **** sv = transaction.savepoint() for word in commonWords: sv2 = transaction.savepoint() data[word.id] = word ************** the last line (print ....) raise an AttributeError: with: **** CODE **** sv = transaction.savepoint() for word in commonWords[0:1]: sv2 = transaction.savepoint() data[word.id] = word ************** all works fine (no AttributeError) obviously if i omit the second savepoint, all works fine if rolling back invalidates the in-memory objects, why without the second savepoint the "id" attribute still exists? thank you david
Description: This is a digitally signed message part
_______________________________________________ For more information about ZODB, see the ZODB Wiki: http://www.zope.org/Wikis/ZODB/ ZODB-Dev mailing list - ZODB-Dev@zope.org http://mail.zope.org/mailman/listinfo/zodb-dev