Commit d6d9fed4 authored by Barry Warsaw's avatar Barry Warsaw

_loadSerialEx(): When lrevid == DNE, we're looking at a George Bailey

moment, i.e. the undo of an object creation.  Return None for the data
in that case.

_TransactionsIterator: Add a _closed flag which gets set in the
close() method, and checked in __getitem__().  Iterating over a closed
iterator raises an IOError.
parent daa67691
...@@ -4,7 +4,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support ...@@ -4,7 +4,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support
undo or versioning. undo or versioning.
""" """
__version__ = '$Revision: 1.37 $'.split()[-2:][0] __version__ = '$Revision: 1.38 $'.split()[-2:][0]
import sys import sys
import struct import struct
...@@ -527,6 +527,10 @@ class Full(BerkeleyBase, ConflictResolvingStorage): ...@@ -527,6 +527,10 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
version = '' version = ''
else: else:
version = self._versions[vid] version = self._versions[vid]
# Check for an zombification event, possible with
# transactionalUndo. Use data==None to specify that.
if lrevid == DNE:
return None, version
return self._pickles[oid+lrevid], version return self._pickles[oid+lrevid], version
finally: finally:
self._lock_release() self._lock_release()
...@@ -1347,6 +1351,7 @@ class _TransactionsIterator: ...@@ -1347,6 +1351,7 @@ class _TransactionsIterator:
def __init__(self, storage): def __init__(self, storage):
self._storage = storage self._storage = storage
self._tid = None self._tid = None
self._closed = 0
def __getitem__(self, i): def __getitem__(self, i):
"""Return the ith item in the sequence of transaction data. """Return the ith item in the sequence of transaction data.
...@@ -1355,11 +1360,16 @@ class _TransactionsIterator: ...@@ -1355,11 +1360,16 @@ class _TransactionsIterator:
RecordsIterator. An IndexError will be raised after all of the items RecordsIterator. An IndexError will be raised after all of the items
have been returned. have been returned.
""" """
if self._closed:
raise IOError, 'iterator is closed'
# Let IndexErrors percolate up. # Let IndexErrors percolate up.
tid, status, user, desc, ext = self._storage._nexttxn(self._tid) tid, status, user, desc, ext = self._storage._nexttxn(self._tid)
self._tid = tid self._tid = tid
return _RecordsIterator(self._storage, tid, status, user, desc, ext) return _RecordsIterator(self._storage, tid, status, user, desc, ext)
def close(self):
self._closed = 1
class _RecordsIterator: class _RecordsIterator:
......
...@@ -4,7 +4,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support ...@@ -4,7 +4,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support
undo or versioning. undo or versioning.
""" """
__version__ = '$Revision: 1.37 $'.split()[-2:][0] __version__ = '$Revision: 1.38 $'.split()[-2:][0]
import sys import sys
import struct import struct
...@@ -527,6 +527,10 @@ class Full(BerkeleyBase, ConflictResolvingStorage): ...@@ -527,6 +527,10 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
version = '' version = ''
else: else:
version = self._versions[vid] version = self._versions[vid]
# Check for an zombification event, possible with
# transactionalUndo. Use data==None to specify that.
if lrevid == DNE:
return None, version
return self._pickles[oid+lrevid], version return self._pickles[oid+lrevid], version
finally: finally:
self._lock_release() self._lock_release()
...@@ -1347,6 +1351,7 @@ class _TransactionsIterator: ...@@ -1347,6 +1351,7 @@ class _TransactionsIterator:
def __init__(self, storage): def __init__(self, storage):
self._storage = storage self._storage = storage
self._tid = None self._tid = None
self._closed = 0
def __getitem__(self, i): def __getitem__(self, i):
"""Return the ith item in the sequence of transaction data. """Return the ith item in the sequence of transaction data.
...@@ -1355,11 +1360,16 @@ class _TransactionsIterator: ...@@ -1355,11 +1360,16 @@ class _TransactionsIterator:
RecordsIterator. An IndexError will be raised after all of the items RecordsIterator. An IndexError will be raised after all of the items
have been returned. have been returned.
""" """
if self._closed:
raise IOError, 'iterator is closed'
# Let IndexErrors percolate up. # Let IndexErrors percolate up.
tid, status, user, desc, ext = self._storage._nexttxn(self._tid) tid, status, user, desc, ext = self._storage._nexttxn(self._tid)
self._tid = tid self._tid = tid
return _RecordsIterator(self._storage, tid, status, user, desc, ext) return _RecordsIterator(self._storage, tid, status, user, desc, ext)
def close(self):
self._closed = 1
class _RecordsIterator: class _RecordsIterator:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment