Commit 5647476b authored by Jim Fulton's avatar Jim Fulton

Only hack tpc_vote if a storage is not read only.

Added deprecation warnings for using versions.
parent 54419e66
...@@ -250,10 +250,10 @@ class DB(object): ...@@ -250,10 +250,10 @@ class DB(object):
except TypeError: except TypeError:
storage.registerDB(self, None) # Backward compat storage.registerDB(self, None) # Backward compat
if not hasattr(storage, 'tpc_vote'): if (not hasattr(storage, 'tpc_vote')) and not storage.isReadOnly():
warnings.warn( warnings.warn(
"Storage doesn't have a tpc_vote and this violates " "Storage doesn't have a tpc_vote and this violates "
"the stirage API. Violently monkeypatching in a do-nothing " "the storage API. Violently monkeypatching in a do-nothing "
"tpc_vote.", "tpc_vote.",
DeprecationWarning, 2) DeprecationWarning, 2)
storage.tpc_vote = lambda *args: None storage.tpc_vote = lambda *args: None
...@@ -370,6 +370,10 @@ class DB(object): ...@@ -370,6 +370,10 @@ class DB(object):
self._r() self._r()
def abortVersion(self, version, txn=None): def abortVersion(self, version, txn=None):
warnings.warn(
"Versions are deprecated and will become unsupported "
"in ZODB 3.9",
DeprecationWarning, 2)
if txn is None: if txn is None:
txn = transaction.get() txn = transaction.get()
txn.register(AbortVersion(self, version)) txn.register(AbortVersion(self, version))
...@@ -487,6 +491,10 @@ class DB(object): ...@@ -487,6 +491,10 @@ class DB(object):
self._storage.close() self._storage.close()
def commitVersion(self, source, destination='', txn=None): def commitVersion(self, source, destination='', txn=None):
warnings.warn(
"Versions are deprecated and will become unsupported "
"in ZODB 3.9",
DeprecationWarning, 2)
if txn is None: if txn is None:
txn = transaction.get() txn = transaction.get()
txn.register(CommitVersion(self, source, destination)) txn.register(CommitVersion(self, source, destination))
...@@ -507,9 +515,17 @@ class DB(object): ...@@ -507,9 +515,17 @@ class DB(object):
return self._storage.getSize() return self._storage.getSize()
def getVersionCacheSize(self): def getVersionCacheSize(self):
warnings.warn(
"Versions are deprecated and will become unsupported "
"in ZODB 3.9",
DeprecationWarning, 2)
return self._version_cache_size return self._version_cache_size
def getVersionPoolSize(self): def getVersionPoolSize(self):
warnings.warn(
"Versions are deprecated and will become unsupported "
"in ZODB 3.9",
DeprecationWarning, 2)
return self._version_pool_size return self._version_pool_size
def invalidate(self, tid, oids, connection=None, version=''): def invalidate(self, tid, oids, connection=None, version=''):
...@@ -559,6 +575,15 @@ class DB(object): ...@@ -559,6 +575,15 @@ class DB(object):
register for afterCompletion() calls. register for afterCompletion() calls.
""" """
if version:
if not self.supportsVersions():
raise ValueError(
"Versions are not supported by this database.")
warnings.warn(
"Versions are deprecated and will become unsupported "
"in ZODB 3.9",
DeprecationWarning, 2)
self._a() self._a()
try: try:
# pool <- the _ConnectionPool for this version # pool <- the _ConnectionPool for this version
...@@ -672,6 +697,10 @@ class DB(object): ...@@ -672,6 +697,10 @@ class DB(object):
self._r() self._r()
def setVersionCacheSize(self, size): def setVersionCacheSize(self, size):
warnings.warn(
"Versions are deprecated and will become unsupported "
"in ZODB 3.9",
DeprecationWarning, 2)
self._a() self._a()
try: try:
self._version_cache_size = size self._version_cache_size = size
...@@ -688,6 +717,10 @@ class DB(object): ...@@ -688,6 +717,10 @@ class DB(object):
self._reset_pool_sizes(size, for_versions=False) self._reset_pool_sizes(size, for_versions=False)
def setVersionPoolSize(self, size): def setVersionPoolSize(self, size):
warnings.warn(
"Versions are deprecated and will become unsupported "
"in ZODB 3.9",
DeprecationWarning, 2)
self._version_pool_size = size self._version_pool_size = size
self._reset_pool_sizes(size, for_versions=True) self._reset_pool_sizes(size, for_versions=True)
......
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