Skip to content

Commit

Permalink
Better historical connection implementation
Browse files Browse the repository at this point in the history
- Lower-weight instances when not using RelStorage

- Still works with new RelStorage instances.

- Doesn't make me include loadBefore in MVCCAdapterInstance objects. :)
  • Loading branch information
Jim Fulton committed Jun 15, 2016
1 parent ebbe9fd commit 61d2c75
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/ZODB/Connection.py
Expand Up @@ -103,9 +103,17 @@ def __init__(self, db, cache_size=400, before=None, cache_size_bytes=0):
# Multi-database support
self.connections = {self._db.database_name: self}

storage = db._mvcc_storage.new_instance()
storage = db._mvcc_storage
if before:
storage = HistoricalStorageAdapter(storage, before)
try:
before_instance = storage.before_instance
except AttributeError:
def before_instance(before):
return HistoricalStorageAdapter(
storage.new_instance(), before)
storage = before_instance(before)
else:
storage = storage.new_instance()

self._normal_storage = self._storage = storage
self.new_oid = db.new_oid
Expand Down
3 changes: 1 addition & 2 deletions src/ZODB/mvccadapter.py
Expand Up @@ -53,7 +53,7 @@ def new_instance(self):
return instance

def before_instance(self, before=None):
return BeforeAdapterInstance(self, before)
return HistoricalStorageAdapter(self._storage, before)

def undo_instance(self):
return UndoAdapterInstance(self)
Expand Down Expand Up @@ -97,7 +97,6 @@ class MVCCAdapterInstance(Base):
_copy_methods = Base._copy_methods + (
'loadSerial', 'new_oid', 'tpc_vote',
'checkCurrentSerialInTransaction', 'tpc_abort',
'loadBefore',
)

def __init__(self, base):
Expand Down

0 comments on commit 61d2c75

Please sign in to comment.