Commit e4544e63 authored by Jeremy Hylton's avatar Jeremy Hylton

Another fix for non-current objects.

In the branches that call loadBefore() or raise ConflictError, make
sure we always return.  Either case satisfies the original call to
setstate() and we don't want to load the current state.
parent cca7cd16
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
############################################################################## ##############################################################################
"""Database connection support """Database connection support
$Id: Connection.py,v 1.112 2004/01/06 03:44:53 jeremy Exp $""" $Id: Connection.py,v 1.113 2004/01/06 17:01:00 jeremy Exp $"""
import logging import logging
import sys import sys
...@@ -477,10 +477,8 @@ class Connection(ExportImport, object): ...@@ -477,10 +477,8 @@ class Connection(ExportImport, object):
if (obj._p_oid in self._invalidated if (obj._p_oid in self._invalidated
and not myhasattr(obj, "_p_independent")): and not myhasattr(obj, "_p_independent")):
# If the object has _p_independent(), we will handle it below. # If the object has _p_independent(), we will handle it below.
if not (self._mvcc and self._setstate_noncurrent(obj)): self._load_before_or_conflict(obj)
self.getTransaction().register(obj) return
self._conflicts[obj._p_oid] = 1
raise ReadConflictError(object=obj)
p, serial = self._storage.load(obj._p_oid, self._version) p, serial = self._storage.load(obj._p_oid, self._version)
self._load_count += 1 self._load_count += 1
...@@ -496,14 +494,21 @@ class Connection(ExportImport, object): ...@@ -496,14 +494,21 @@ class Connection(ExportImport, object):
# This call will raise a ReadConflictError if something # This call will raise a ReadConflictError if something
# goes wrong # goes wrong
self._handle_independent(obj) self._handle_independent(obj)
elif not (self._mvcc and self._setstate_noncurrent(obj)): else:
self.getTransaction().register(obj) self._load_before_or_conflict(obj)
self._conflicts[obj._p_oid] = 1 return
raise ReadConflictError(object=obj)
self._reader.setGhostState(obj, p) self._reader.setGhostState(obj, p)
obj._p_serial = serial obj._p_serial = serial
def _load_before_or_conflict(self, obj):
"""Load non-current state for obj or raise ReadConflictError."""
if not (self._mvcc and self._setstate_noncurrent(obj)):
self.getTransaction().register(obj)
self._conflicts[obj._p_oid] = 1
raise ReadConflictError(object=obj)
def _setstate_noncurrent(self, obj): def _setstate_noncurrent(self, obj):
"""Set state using non-current data. """Set state using non-current data.
......
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