Commit ad25595e authored by Jim Fulton's avatar Jim Fulton

Refactred the way historical connections work to work with RelStorage

parent fad84bd6
...@@ -49,6 +49,8 @@ from ZODB.utils import p64, u64, z64, oid_repr, positive_id ...@@ -49,6 +49,8 @@ from ZODB.utils import p64, u64, z64, oid_repr, positive_id
from ZODB import utils from ZODB import utils
import six import six
from .mvccadapter import HistoricalStorageAdapter
global_reset_counter = 0 global_reset_counter = 0
noop = lambda : None noop = lambda : None
...@@ -101,11 +103,10 @@ class Connection(ExportImport, object): ...@@ -101,11 +103,10 @@ class Connection(ExportImport, object):
# Multi-database support # Multi-database support
self.connections = {self._db.database_name: self} self.connections = {self._db.database_name: self}
storage = db._mvcc_storage
if before: if before:
storage = storage.before_instance(before) storage = HistoricalStorageAdapter(db.storage, before)
else: else:
storage = storage.new_instance() storage = db._mvcc_storage.new_instance()
self._normal_storage = self._storage = storage self._normal_storage = self._storage = storage
self.new_oid = db.new_oid self.new_oid = db.new_oid
...@@ -308,7 +309,7 @@ class Connection(ExportImport, object): ...@@ -308,7 +309,7 @@ class Connection(ExportImport, object):
"""Returns True if this connection is read only.""" """Returns True if this connection is read only."""
if self.opened is None: if self.opened is None:
raise ConnectionStateError("The database connection is closed") raise ConnectionStateError("The database connection is closed")
return self.before is not None or self._storage.isReadOnly() return self._storage.isReadOnly()
@property @property
def root(self): def root(self):
......
...@@ -177,15 +177,17 @@ class MVCCAdapterInstance(Base): ...@@ -177,15 +177,17 @@ class MVCCAdapterInstance(Base):
def read_only_writer(self, *a, **kw): def read_only_writer(self, *a, **kw):
raise POSException.ReadOnlyError raise POSException.ReadOnlyError
class BeforeAdapterInstance(Base): class HistoricalStorageAdapter(Base):
"""Adapt a storage to a historical storage
"""
_copy_methods = Base._copy_methods + ( _copy_methods = Base._copy_methods + (
'loadSerial', 'tpc_begin', 'tpc_finish', 'tpc_abort', 'tpc_vote', 'loadSerial', 'tpc_begin', 'tpc_finish', 'tpc_abort', 'tpc_vote',
'checkCurrentSerialInTransaction', 'checkCurrentSerialInTransaction',
) )
def __init__(self, base, before=None): def __init__(self, storage, before=None):
Base.__init__(self, base._storage) Base.__init__(self, storage)
self._before = before self._before = before
def isReadOnly(self): def isReadOnly(self):
......
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