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