Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to make tests pass with https://github.com/zopefoundation/ZODB/pull/66 #45

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 35 additions & 31 deletions relstorage/__init__.py
Expand Up @@ -29,35 +29,39 @@ def check_compatible():

check_compatible()

try:
import ZODB.mvccadapter # check or ZODB5, which doesn't need the patch
except ImportError:

def patch_zodb_sync():
"""Patch Connection.sync() and afterCompletion() to pass the 'force' flag.
"""

def _storage_sync(self, *ignored, **kw):
if hasattr(self, '_readCurrent'):
self._readCurrent.clear()
sync = getattr(self._storage, 'sync', 0)
if sync:
# By default, do not force the sync, allowing RelStorage
# to ignore sync requests for a while.
force = kw.get('force', False)
try:
sync(force=force)
except TypeError:
# The 'force' parameter is not accepted.
sync()
self._flush_invalidations()

def sync(self):
"""Manually update the view on the database."""
self.transaction_manager.abort()
self._storage_sync(force=True)

from ZODB.Connection import Connection
Connection._storage_sync = _storage_sync
Connection.afterCompletion = _storage_sync
Connection.newTransaction = _storage_sync
Connection.sync = sync

patch_zodb_sync()
def patch_zodb_sync():
"""Patch Connection.sync() and afterCompletion()
to pass the 'force' flag.
"""

def _storage_sync(self, *ignored, **kw):
if hasattr(self, '_readCurrent'):
self._readCurrent.clear()
sync = getattr(self._storage, 'sync', 0)
if sync:
# By default, do not force the sync, allowing RelStorage
# to ignore sync requests for a while.
force = kw.get('force', False)
try:
sync(force=force)
except TypeError:
# The 'force' parameter is not accepted.
sync()
self._flush_invalidations()

def sync(self):
"""Manually update the view on the database."""
self.transaction_manager.abort()
self._storage_sync(force=True)

from ZODB.Connection import Connection
Connection._storage_sync = _storage_sync
Connection.afterCompletion = _storage_sync
Connection.newTransaction = _storage_sync
Connection.sync = sync

patch_zodb_sync()
2 changes: 1 addition & 1 deletion relstorage/storage.py
Expand Up @@ -253,7 +253,7 @@ def _rollback_load_connection(self):
self._load_conn.rollback()
except:
self._drop_load_connection()
raise
#raise
self._load_transaction_open = ''

def _restart_load_and_call(self, f, *args, **kw):
Expand Down
2 changes: 1 addition & 1 deletion relstorage/tests/blob/blob_connection.txt
Expand Up @@ -74,7 +74,7 @@ You can't put blobs into a database that has uses a Non-Blob-Storage, though:
>>> transaction2.commit() # doctest: +ELLIPSIS
Traceback (most recent call last):
...
Unsupported: Storing Blobs in <ZODB.MappingStorage.MappingStorage ...> is not supported.
Unsupported: Storing Blobs in ...

>>> transaction2.abort()
>>> connection2.close()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -76,7 +76,7 @@ def read_file(*path):
zip_safe=False, # otherwise ZConfig can't see component.xml
install_requires=[
'perfmetrics',
'ZODB >= 4.3.0, <5.0',
'ZODB >= 4.3.0',
# ZEO is needed for blob layout
'ZEO >= 4.2.0b1, <5.0',
'zope.interface',
Expand Down