Commit e7574978 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 2b9759a9
...@@ -178,14 +178,13 @@ will be our future approach after we teach NEO about object deduplication. ...@@ -178,14 +178,13 @@ will be our future approach after we teach NEO about object deduplication.
from wendelin.bigfile import WRITEOUT_STORE, WRITEOUT_MARKSTORED from wendelin.bigfile import WRITEOUT_STORE, WRITEOUT_MARKSTORED
from wendelin.bigfile._file_zodb import _ZBigFile from wendelin.bigfile._file_zodb import _ZBigFile
from wendelin.lib.mem import bzero, memcpy from wendelin.lib.mem import bzero, memcpy
from wendelin.lib.zodb import LivePersistent, deactivate_btree, zconn_at from wendelin.lib.zodb import LivePersistent, deactivate_btree
from transaction.interfaces import IDataManager, ISynchronizer from transaction.interfaces import IDataManager, ISynchronizer
from persistent import Persistent, PickleCache, GHOST from persistent import Persistent, GHOST
from BTrees.LOBTree import LOBTree from BTrees.LOBTree import LOBTree
from BTrees.IOBTree import IOBTree from BTrees.IOBTree import IOBTree
from zope.interface import implementer from zope.interface import implementer
from ZODB.Connection import Connection
from weakref import WeakSet from weakref import WeakSet
import os import os
...@@ -637,36 +636,6 @@ class ZBigFile(LivePersistent): ...@@ -637,36 +636,6 @@ class ZBigFile(LivePersistent):
# patch for ZODB.Connection to support callback on .open()
# NOTE on-open callbacks are setup once and fire many times on every open
# on-close callbacks are setup once and fire only once on next close
Connection._onOpenCallbacks = None
def Connection_onOpenCallback(self, f):
if self._onOpenCallbacks is None:
# NOTE WeakSet does not work for bound methods - they are always created
# anew for each obj.method access, and thus will go away almost immediately
self._onOpenCallbacks = WeakSet()
self._onOpenCallbacks.add(f)
assert not hasattr(Connection, 'onOpenCallback')
Connection.onOpenCallback = Connection_onOpenCallback
orig_Connection_open = Connection.open
def Connection_open(self, transaction_manager=None, delegate=True):
orig_Connection_open(self, transaction_manager, delegate)
# FIXME method name hardcoded. Better not do it and allow f to be general
# callable, but that does not work with bound method - see above.
# ( Something like WeakMethod from py3 could help )
if self._onOpenCallbacks:
for f in self._onOpenCallbacks:
f.on_connection_open()
Connection.open = Connection_open
# ------------
# BigFileH wrapper that also acts as DataManager proxying changes back to ZODB # BigFileH wrapper that also acts as DataManager proxying changes back to ZODB
# objects at two-phase-commit (TPC) level. # objects at two-phase-commit (TPC) level.
# XXX and ZODB -> virtmem invalidation. # XXX and ZODB -> virtmem invalidation.
......
...@@ -233,6 +233,33 @@ def _zmajor(): ...@@ -233,6 +233,33 @@ def _zmajor():
zmajor = _zmajor() zmajor = _zmajor()
# patch for ZODB.Connection to support callback on .open()
# NOTE on-open callbacks are setup once and fire many times on every open
# on-close callbacks are setup once and fire only once on next close
ZODB.Connection.Connection._onOpenCallbacks = None
def Connection_onOpenCallback(self, f):
if self._onOpenCallbacks is None:
# NOTE WeakSet does not work for bound methods - they are always created
# anew for each obj.method access, and thus will go away almost immediately
self._onOpenCallbacks = WeakSet()
self._onOpenCallbacks.add(f)
assert not hasattr(ZODB.Connection.Connection, 'onOpenCallback')
ZODB.Connection.Connection.onOpenCallback = Connection_onOpenCallback
_orig_Connection_open = ZODB.Connection.Connection.open
def Connection_open(self, transaction_manager=None, delegate=True):
_orig_Connection_open(self, transaction_manager, delegate)
# FIXME method name hardcoded. Better not do it and allow f to be general
# callable, but that does not work with bound method - see above.
# ( Something like WeakMethod from py3 could help )
if self._onOpenCallbacks:
for f in self._onOpenCallbacks:
f.on_connection_open()
ZODB.Connection.Connection.open = Connection_open
# patch for ZODB.Connection to support callback on after database view is changed # patch for ZODB.Connection to support callback on after database view is changed
ZODB.Connection.Connection._onResyncCallbacks = None ZODB.Connection.Connection._onResyncCallbacks = None
......
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