Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Kirill Smelkov
Zope
Commits
4acb7afa
Commit
4acb7afa
authored
Mar 27, 2001
by
Chris McDonough
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge from PacklessBerkeley3Storage branch.
parent
cd119fc0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
21 deletions
+29
-21
lib/python/BDBStorage/Packless.py
lib/python/BDBStorage/Packless.py
+12
-9
lib/python/BDBStorage/base.py
lib/python/BDBStorage/base.py
+17
-12
No files found.
lib/python/BDBStorage/Packless.py
View file @
4acb7afa
...
...
@@ -88,9 +88,9 @@ counting garbage-collection strategy which necessitates packing only when
the stored data has cyclically-referenced garbage.
"""
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
from
base
import
Base
from
base
import
Base
,
DBError
from
base
import
BerkeleyDBError
from
bsddb3
import
db
from
struct
import
pack
,
unpack
...
...
@@ -129,6 +129,9 @@ class Packless(Base):
"""
return
'current'
,
'referenceCount'
,
'oreferences'
,
'opickle'
def
_abort
(
self
):
pass
def
load
(
self
,
oid
,
version
):
self
.
_lock_acquire
()
try
:
...
...
@@ -136,7 +139,7 @@ class Packless(Base):
s
=
self
.
_index
[
oid
]
p
=
self
.
_opickle
[
oid
]
return
p
,
s
# pickle, serial
except
db
.
e
rror
,
msg
:
except
DBE
rror
,
msg
:
raise
BerkeleyDBError
,
(
"%s (%s)"
%
(
BerkeleyDBError
.
__doc__
,
msg
)
)
...
...
@@ -200,8 +203,8 @@ class Packless(Base):
referenced
=
references
.
has_key
# Create refcnt
if
not
referenceCount_get
(
oid
,
txn
):
referenceCount_put
(
oid
,
'
\
0
'
*
intlen
,
txn
)
if
not
referenceCount_get
(
oid
,
txn
=
txn
):
referenceCount_put
(
oid
,
'
\
0
'
*
intlen
,
txn
=
txn
)
# zeros[oid]=1
# ^^^^^^^^^^^^
# this should happen when ZODB import is fixed
...
...
@@ -228,7 +231,7 @@ class Packless(Base):
c
.
delete
()
# decrement refcnt:
rc
=
unpack
(
">i"
,
referenceCount_get
(
roid
,
txn
))[
0
]
referenceCount_get
(
roid
,
txn
=
txn
))[
0
]
rc
=
rc
-
1
if
rc
<
0
:
# This should never happen
...
...
@@ -248,7 +251,7 @@ class Packless(Base):
oreferences_put
(
oid
,
roid
,
txn
)
# Create/update refcnt
rcs
=
referenceCount_get
(
roid
,
txn
)
rcs
=
referenceCount_get
(
roid
,
txn
=
txn
)
if
rcs
:
rc
=
unpack
(
">i"
,
rcs
)[
0
]
if
rc
==
0
:
...
...
@@ -275,7 +278,7 @@ class Packless(Base):
tmp
.
seek
(
0
)
if
fsize
>
MAXTEMPFSIZE
:
tmp
.
truncate
()
except
db
.
e
rror
,
msg
:
except
DBE
rror
,
msg
:
try
:
txn
.
abort
()
except
db
.
error
,
msg
:
...
...
@@ -310,7 +313,7 @@ class Packless(Base):
roid
=
roid
[
1
]
# decrement refcnt:
rc
=
referenceCount_get
(
roid
,
txn
)
rc
=
referenceCount_get
(
roid
,
txn
=
txn
)
if
rc
:
rc
=
unpack
(
">i"
,
rc
)[
0
]
-
1
if
rc
<
0
:
...
...
lib/python/BDBStorage/base.py
View file @
4acb7afa
...
...
@@ -84,19 +84,29 @@
##############################################################################
""" Base module for BerkeleyStorage implementations """
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
from
ZODB.BaseStorage
import
BaseStorage
from
ZODB
import
POSException
from
bsddb3
import
db
import
os
,
tempfile
try
:
DB
=
db
.
DB
DBEnv
=
db
.
DBEnv
DBError
=
db
.
DBError
except
:
DB
=
db
.
Db
DBEnv
=
db
.
DbEnv
DBError
=
db
.
error
class
BerkeleyDBError
(
POSException
.
POSError
):
""" A BerkeleyDB exception occurred. This probably indicates that
there is a low memory condition, a tempfile space shortage, or
a space shortage in the directory which houses the BerkeleyDB log
files. Check available tempfile space, logfile space, and RAM and
restart the server process."""
restart the server process. This error could have additionally
been caused by too few locks available to BerkeleyDB for the
transaction size you were attempting to commit."""
class
Base
(
BaseStorage
):
...
...
@@ -118,7 +128,7 @@ class Base(BaseStorage):
def
_setupDB
(
self
,
name
,
flags
=
0
):
"""Open an individual database and assign to an "_" attribute.
"""
d
=
db
.
Db
(
self
.
_env
)
d
=
DB
(
self
.
_env
)
if
flags
:
d
.
set_flags
(
flags
)
d
.
open
(
self
.
_prefix
+
name
,
db
.
DB_BTREE
,
db
.
DB_CREATE
)
setattr
(
self
,
'_'
+
name
,
d
)
...
...
@@ -152,12 +162,6 @@ class Base(BaseStorage):
# TBD
return
0
def
_finish
(
self
,
tid
,
user
,
desc
,
ext
):
self
.
_txn
.
commit
()
def
_abort
(
self
,
tid
,
user
,
desc
,
ext
):
self
.
_txn
.
abort
()
def
_clear_temp
(
self
):
self
.
_tmp
.
seek
(
0
)
...
...
@@ -182,12 +186,13 @@ def envFromString(name):
if
not
os
.
path
.
exists
(
name
):
os
.
mkdir
(
name
)
except
:
raise
"Error creating BerkeleyDB environment dir: %s"
%
name
e
=
db
.
DbEnv
()
e
=
DBEnv
()
e
.
set_lk_max
(
10000
)
# this can be overridden in the DB_CONFIG file
try
:
e
.
open
(
name
,
db
.
DB_CREATE
|
db
.
DB_RECOVER
|
db
.
DB_INIT_MPOOL
|
db
.
DB_INIT_LOCK
|
db
.
DB_INIT_TXN
)
except
db
.
e
rror
,
msg
:
except
DBE
rror
,
msg
:
raise
BerkeleyDBError
,
"%s (%s)"
%
(
BerkeleyDBError
.
__doc__
,
msg
)
return
e
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