Commit 4eda7e6d authored by Jeremy Hylton's avatar Jeremy Hylton

Eliminate duplicate code in _handle_serials().

parent cacef1dc
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
############################################################################## ##############################################################################
"""Database connection support """Database connection support
$Id: Connection.py,v 1.95 2003/06/13 16:54:43 jeremy Exp $""" $Id: Connection.py,v 1.96 2003/06/13 17:00:04 jeremy Exp $"""
from __future__ import nested_scopes from __future__ import nested_scopes
...@@ -725,31 +725,24 @@ class Connection(ExportImport.ExportImport): ...@@ -725,31 +725,24 @@ class Connection(ExportImport.ExportImport):
if not store_return: if not store_return:
return return
if isinstance(store_return, StringType): if isinstance(store_return, StringType):
# This code is duplicated in the body of the for loop below.
assert oid is not None assert oid is not None
serial = store_return self._handle_one_serial(oid, store_return, change)
obj = self._cache.get(oid, None)
if obj is None:
return
if serial == ResolvedSerial:
del obj._p_changed # transition from changed to ghost
else:
if change:
obj._p_changed = 0 # transition from changed to uptodate
obj._p_serial = serial
else: else:
for oid, serial in store_return: for oid, serial in store_return:
if not isinstance(serial, StringType): self._handle_one_serial(oid, serial, change)
raise serial
obj = self._cache.get(oid, None) def _handle_one_serial(self, oid, serial, change):
if obj is None: if not isinstance(serial, StringType):
continue raise serial
if serial == ResolvedSerial: obj = self._cache.get(oid, None)
del obj._p_changed # transition from changed to ghost if obj is None:
else: return
if change: if serial == ResolvedSerial:
obj._p_changed = 0 # trans. from changed to uptodate del obj._p_changed # transition from changed to ghost
obj._p_serial = serial else:
if change:
obj._p_changed = 0 # trans. from changed to uptodate
obj._p_serial = serial
def tpc_finish(self, transaction): def tpc_finish(self, transaction):
# It's important that the storage call the function we pass # It's important that the storage call the function we pass
......
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