Commit 0cbf4db6 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 338231dd
......@@ -57,6 +57,7 @@ from cpython cimport PyCapsule_New
from ZODB.Connection import Connection as ZConnection
from ZODB.utils import u64
from wendelin.lib.zodb import zconn_at
import weakref
# _ZBigFile is base class for ZBigFile that provides BigFile-line base.
......@@ -155,18 +156,18 @@ cdef wcfs.PyConn pywconnOf(zconn):
# ZSync keeps wconn in sync with zconn.
# XXX -> make generic and use for _ZBigFileH too?
# -> y: ZSync base + ZSyncWConn, ZSyncBigFileH
# XXX naming? -> ZKeepInSync ?
#
# wconn will be closed once zconn is destroyed (not closed, which returns it
# back into DB pool).
class ZSync:
# .zconn
# .wconn
# .zconn_ref weakref[zodb.Connection]
# .wconn (py) wcfs.Connection
def __init__(zsync, zconn, wconn):
#print('ZSync %r %r' % (zconn, wconn))
assert zconn.open
zsync.zconn = zconn # XXX -> weakref
zsync.wconn = wconn
zsync.wconn = wconn
zsync.zconn_ref = weakref.ref(zconn, zsync.on_zconn_dealloc)
# NOTE zconn.onOpenCallback is not enough: zconn.at can change even
# without zconn.close/zconn.open, e.g.:
......@@ -175,11 +176,14 @@ class ZSync:
# tm.commit() # zconn.at updated again
zconn.onResyncCallback(zsync)
# TODO zconn dealloc -> wconn.close
# .zconn dealloc -> wconn.close
def on_zconn_dealloc(zsync, _):
zsync.wconn.close()
# DB resyncs .zconn onto new database view.
# -> resync .wconn to updated database view of ZODB connection.
def on_connection_resync(zsync):
#print('\nZZZSync.resync %r %r' % (zsync.zconn, zsync.wconn))
#import traceback; traceback.print_stack()
zsync.wconn.resync(zconn_at(zsync.zconn))
zconn = zsync.zconn_ref()
zsync.wconn.resync(zconn_at(zconn))
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