[Zodb-checkins] CVS: ZODB3/ZODB - BaseStorage.py:1.36.2.2
Jeremy Hylton
cvs-admin at zope.org
Wed Nov 12 12:28:46 EST 2003
Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv3179/ZODB
Modified Files:
Tag: ZODB3-mvcc-2-branch
BaseStorage.py
Log Message:
Several fixes to default (and perhaps useless) loadNonCurrent().
Allow it to return current data with an end_tid of None. This seems
wrong given the name, but doesn't seem work preventing.
Make sure the "while start_time is None" exits. If it couldn't find
any data in history() it would run forever. The history() call was
botched because it didn't pass size, and thus passed the filter as the
size. (Python helpfully allows me to compare an int to a lambda.)
If no data is found via history(), return None.
=== ZODB3/ZODB/BaseStorage.py 1.36.2.1 => 1.36.2.2 ===
--- ZODB3/ZODB/BaseStorage.py:1.36.2.1 Tue Oct 7 01:10:32 2003
+++ ZODB3/ZODB/BaseStorage.py Wed Nov 12 12:28:45 2003
@@ -249,8 +249,14 @@
def loadNonCurrent(self, oid, tid):
"""Return most recent revision of oid before tid committed."""
+ # XXX Is it okay for loadNonCurrent() to return current data?
+ # There doesn't seem to be a good reason to forbid it, even
+ # though the typical use of this method will never find
+ # current data. But maybe we should call it loadByTid()?
+
n = 2
start_time = None
+ end_time = None
while start_time is None:
# The history() approach is a hack, because the dict
# returned by history() doesn't contain a tid. It
@@ -262,14 +268,18 @@
# the pack time, we can't honor the MVCC request.
# Note: history() returns the most recent record first.
- L = self.history(oid, "", lambda d: not d["version"])
+ L = self.history(oid, "", n, lambda d: not d["version"])
for d in L:
if d["serial"] < tid:
start_time = d["serial"]
break
else:
end_time = d["serial"]
+ if len(L) < n:
+ break
n *= 2
+ if start_time is None:
+ return None
data = self.loadSerial(oid, start_time)
return data, start_time, start_time, end_time
More information about the Zodb-checkins
mailing list