Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
e7574978
Commit
e7574978
authored
Apr 01, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2b9759a9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
33 deletions
+29
-33
bigfile/file_zodb.py
bigfile/file_zodb.py
+2
-33
lib/zodb.py
lib/zodb.py
+27
-0
No files found.
bigfile/file_zodb.py
View file @
e7574978
...
...
@@ -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._file_zodb
import
_ZBigFile
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
persistent
import
Persistent
,
PickleCache
,
GHOST
from
persistent
import
Persistent
,
GHOST
from
BTrees.LOBTree
import
LOBTree
from
BTrees.IOBTree
import
IOBTree
from
zope.interface
import
implementer
from
ZODB.Connection
import
Connection
from
weakref
import
WeakSet
import
os
...
...
@@ -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
# objects at two-phase-commit (TPC) level.
# XXX and ZODB -> virtmem invalidation.
...
...
lib/zodb.py
View file @
e7574978
...
...
@@ -233,6 +233,33 @@ def _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
ZODB
.
Connection
.
Connection
.
_onResyncCallbacks
=
None
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment