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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
fdc76cf4
Commit
fdc76cf4
authored
Dec 12, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
5fb60c76
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
3 deletions
+59
-3
bigfile/file_zodb.py
bigfile/file_zodb.py
+2
-2
lib/zodb.py
lib/zodb.py
+57
-1
No files found.
bigfile/file_zodb.py
View file @
fdc76cf4
...
@@ -178,7 +178,7 @@ will be our future approach after we teach NEO about object deduplication.
...
@@ -178,7 +178,7 @@ will be our future approach after we teach NEO about object deduplication.
from
wendelin.bigfile
import
BigFile
,
WRITEOUT_STORE
,
WRITEOUT_MARKSTORED
from
wendelin.bigfile
import
BigFile
,
WRITEOUT_STORE
,
WRITEOUT_MARKSTORED
from
wendelin
import
wcfs
from
wendelin
import
wcfs
from
wendelin.lib.mem
import
bzero
,
memcpy
from
wendelin.lib.mem
import
bzero
,
memcpy
from
wendelin.lib.zodb
import
deactivate_btree
from
wendelin.lib.zodb
import
deactivate_btree
,
zconn_at
from
transaction.interfaces
import
IDataManager
,
ISynchronizer
from
transaction.interfaces
import
IDataManager
,
ISynchronizer
from
persistent
import
Persistent
,
PickleCache
,
GHOST
from
persistent
import
Persistent
,
PickleCache
,
GHOST
...
@@ -666,7 +666,7 @@ class ZBigFile(LivePersistent):
...
@@ -666,7 +666,7 @@ class ZBigFile(LivePersistent):
zstor
=
zconn
.
db
().
storage
zstor
=
zconn
.
db
().
storage
zurl
=
wcfs
.
zstor_2zurl
(
zstor
)
zurl
=
wcfs
.
zstor_2zurl
(
zstor
)
wc
=
wcfs
.
join
(
zurl
)
wc
=
wcfs
.
join
(
zurl
)
wconn
=
wc
.
connect
(
zconn
.
at
(
))
wconn
=
wc
.
connect
(
zconn
_at
(
zconn
))
wcfileh
=
wconn
.
open
(
self
.
_p_oid
)
wcfileh
=
wconn
.
open
(
self
.
_p_oid
)
fileh
=
_ZBigFileH
(
self
,
wcfileh
)
fileh
=
_ZBigFileH
(
self
,
wcfileh
)
...
...
lib/zodb.py
View file @
fdc76cf4
# Wendelin.bigfile | common ZODB-related helpers
# Wendelin.bigfile | common ZODB-related helpers
# Copyright (C) 2014-201
5
Nexedi SA and Contributors.
# Copyright (C) 2014-201
9
Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
# Kirill Smelkov <kirr@nexedi.com>
#
#
# This program is free software: you can Use, Study, Modify and Redistribute
# This program is free software: you can Use, Study, Modify and Redistribute
...
@@ -17,12 +17,17 @@
...
@@ -17,12 +17,17 @@
#
#
# See COPYING file for full licensing terms.
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
# See https://www.nexedi.com/licensing for rationale and options.
"""Package wendelin.lib.zodb provides ZODB-related utilitiy functions."""
import
ZODB
from
ZODB.FileStorage
import
FileStorage
from
ZODB.FileStorage
import
FileStorage
from
ZODB
import
DB
from
ZODB
import
DB
from
ZODB.utils
import
p64
,
u64
from
persistent
import
Persistent
from
persistent
import
Persistent
import
gc
import
gc
import
pkg_resources
# open db storage by uri
# open db storage by uri
def
dbstoropen
(
uri
):
def
dbstoropen
(
uri
):
...
@@ -105,3 +110,54 @@ def _deactivate_bucket(bucket):
...
@@ -105,3 +110,54 @@ def _deactivate_bucket(bucket):
obj
.
_p_deactivate
()
obj
.
_p_deactivate
()
bucket
.
_p_deactivate
()
bucket
.
_p_deactivate
()
# zconn_at returns tid as of which ZODB connection is viewing the database.
def
zconn_at
(
zconn
):
# -> tid
assert
isinstance
(
zconn
,
ZODB
.
Connection
.
Connection
)
# ZODB5 uses MVCC uniformly
if
zmajor
>=
5
:
zstor
=
zconn
.
_storage
if
isinstance
(
zstor
,
ZODB
.
mvccadapter
.
MVCCAdapterInstance
):
# XXX there is race in ZODB itself that leads to data corruption:
# https://github.com/zopefoundation/ZODB/issues/290
return
before2at
(
zstor
.
_start
)
if
isinstance
(
zstor
,
ZODB
.
mvccadapter
.
HistoricalStorageAdapter
):
return
before2at
(
zstor
.
_before
)
raise
AssertionError
(
"zconn_at: TODO: add support for zstor %r"
%
zstor
)
raise
AssertionError
(
"zconn_at: TODO: add support for ZODB34"
)
# before2at converts tid that specifies database state as "before" into tid that
# specifies database state as "at".
def
before2at
(
before
):
# -> at
return
p64
(
u64
(
before
)
-
1
)
# _zversion returns ZODB version object
def
_zversion
():
dzodb3
=
pkg_resources
.
working_set
.
find
(
pkg_resources
.
Requirement
.
parse
(
'ZODB3'
))
dzodb
=
pkg_resources
.
working_set
.
find
(
pkg_resources
.
Requirement
.
parse
(
'ZODB'
))
v311
=
pkg_resources
.
parse_version
(
'3.11dev'
)
vzodb3
=
dzodb3
.
parsed_version
if
dzodb3
is
not
None
and
vzodb3
>=
v311
:
vzodb
=
dzodb
.
parsed_version
# ZODB 3.11 just requires latest ZODB & ZEO
else
:
vzodb
=
vzodb3
assert
vzodb
is
not
None
return
vzodb
# _zmajor returns major ZODB version.
def
_zmajor
():
vzodb
=
_zversion
()
# XXX hack - packaging.version.Version provides no way to extract major?
return
int
(
vzodb
.
public
.
split
(
'.'
)[
0
])
# 3.11.dev0 -> 3
# zmajor is set to major ZODB version.
zmajor
=
_zmajor
()
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