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
042f0abc
Commit
042f0abc
authored
Aug 28, 2002
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup.
parent
41409b00
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
38 deletions
+26
-38
lib/python/BDBStorage/BDBFullStorage.py
lib/python/BDBStorage/BDBFullStorage.py
+13
-19
lib/python/BDBStorage/Full.py
lib/python/BDBStorage/Full.py
+13
-19
No files found.
lib/python/BDBStorage/BDBFullStorage.py
View file @
042f0abc
...
...
@@ -18,7 +18,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support
undo or versioning.
"""
__version__
=
'$Revision: 1.4
2
$'
.
split
()[
-
2
:][
0
]
__version__
=
'$Revision: 1.4
3
$'
.
split
()[
-
2
:][
0
]
import
sys
import
struct
...
...
@@ -463,8 +463,7 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
# We've already dealt with this oid...
continue
serial
,
tid
=
self
.
_getSerialAndTid
(
oid
)
revid
=
tid
meta
=
self
.
_metadata
[
oid
+
revid
]
meta
=
self
.
_metadata
[
oid
+
tid
]
curvid
,
nvrevid
=
struct
.
unpack
(
'>8s8s'
,
meta
[:
16
])
# Make sure that the vid in the metadata record is the same as
# the vid we sucked out of the vids table.
...
...
@@ -484,7 +483,7 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
# Write the object id, live revision id, the current revision
# id (which serves as the previous revid to this transaction)
# to the commit log.
self
.
_commitlog
.
write_nonversion_object
(
oid
,
lrevid
,
rev
id
)
self
.
_commitlog
.
write_nonversion_object
(
oid
,
lrevid
,
t
id
)
# Remember to return the oid...
oids
[
oid
]
=
1
# We've now processed all the objects on the discarded version, so
...
...
@@ -534,8 +533,7 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
if
oids
.
has_key
(
oid
):
continue
serial
,
tid
=
self
.
_getSerialAndTid
(
oid
)
revid
=
tid
meta
=
self
.
_metadata
[
oid
+
revid
]
meta
=
self
.
_metadata
[
oid
+
tid
]
curvid
,
nvrevid
,
lrevid
=
struct
.
unpack
(
'>8s8s8s'
,
meta
[:
24
])
# Our database better be consistent.
if
curvid
<>
svid
:
...
...
@@ -548,7 +546,7 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
if
not
dest
:
nvrevid
=
ZERO
self
.
_commitlog
.
write_moved_object
(
oid
,
dvid
,
nvrevid
,
lrevid
,
rev
id
)
oid
,
dvid
,
nvrevid
,
lrevid
,
t
id
)
# Remember to return the oid...
oids
[
oid
]
=
1
# Now that we're done, we can discard this version
...
...
@@ -567,8 +565,7 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
try
:
# Let KeyErrors percolate up
serial
,
tid
=
self
.
_getSerialAndTid
(
oid
)
revid
=
tid
vid
=
self
.
_metadata
[
oid
+
revid
][:
8
]
vid
=
self
.
_metadata
[
oid
+
tid
][:
8
]
if
vid
==
ZERO
:
# Not in a version
return
''
...
...
@@ -596,11 +593,10 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
# Get the current revid for the object. As per the protocol, let
# any KeyErrors percolate up.
serial
,
tid
=
self
.
_getSerialAndTid
(
oid
)
revid
=
tid
# Get the metadata associated with this revision of the object.
# All we really need is the vid, the non-version revid and the
# pickle pointer revid.
rec
=
self
.
_metadata
[
oid
+
rev
id
]
rec
=
self
.
_metadata
[
oid
+
t
id
]
vid
,
nvrevid
,
lrevid
=
struct
.
unpack
(
'>8s8s8s'
,
rec
[:
24
])
if
lrevid
==
DNE
:
raise
KeyError
,
'Object does not exist'
...
...
@@ -1060,15 +1056,14 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
# the transaction records backwards until we find enough records.
history
=
[]
serial
,
tid
=
self
.
_getSerialAndTid
(
oid
)
revid
=
tid
# BAW: Again, let KeyErrors percolate up
while
len
(
history
)
<
size
:
# Some information comes out of the revision metadata...
vid
,
nvrevid
,
lrevid
,
previd
=
struct
.
unpack
(
'>8s8s8s8s'
,
self
.
_metadata
[
oid
+
rev
id
])
'>8s8s8s8s'
,
self
.
_metadata
[
oid
+
t
id
])
# ...while other information comes out of the transaction
# metadata.
txnmeta
=
self
.
_txnMetadata
[
rev
id
]
txnmeta
=
self
.
_txnMetadata
[
t
id
]
userlen
,
desclen
=
struct
.
unpack
(
'>II'
,
txnmeta
[
1
:
9
])
user
=
txnmeta
[
9
:
9
+
userlen
]
desc
=
txnmeta
[
9
+
userlen
:
9
+
userlen
+
desclen
]
...
...
@@ -1082,7 +1077,7 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
else
:
retvers
=
self
.
_versions
[
vid
]
# The HistoryEntry object
d
=
{
'time'
:
TimeStamp
(
rev
id
).
timeTime
(),
d
=
{
'time'
:
TimeStamp
(
t
id
).
timeTime
(),
'user_name'
:
user
,
'description'
:
desc
,
'serial'
:
serial
,
...
...
@@ -1095,7 +1090,7 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
# revision, stopping when we've reached the end.
if
previd
==
ZERO
:
break
serial
=
rev
id
=
previd
serial
=
t
id
=
previd
return
history
finally
:
self
.
_lock_release
()
...
...
@@ -1119,12 +1114,11 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
reachables
[
oid
]
=
1
# Get the pickle data for the object's current version
serial
,
tid
=
self
.
_getSerialAndTidMissingOk
(
oid
)
revid
=
tid
if
revid
is
None
:
if
tid
is
None
:
# BAW: how can this happen?! This means that an object is
# holding references to an object that we know nothing about.
continue
lrevid
=
self
.
_metadata
[
oid
+
rev
id
][
16
:
24
]
lrevid
=
self
.
_metadata
[
oid
+
t
id
][
16
:
24
]
pickle
=
self
.
_pickles
[
oid
+
lrevid
]
refdoids
=
[]
referencesf
(
pickle
,
refdoids
)
...
...
lib/python/BDBStorage/Full.py
View file @
042f0abc
...
...
@@ -18,7 +18,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support
undo or versioning.
"""
__version__
=
'$Revision: 1.4
2
$'
.
split
()[
-
2
:][
0
]
__version__
=
'$Revision: 1.4
3
$'
.
split
()[
-
2
:][
0
]
import
sys
import
struct
...
...
@@ -463,8 +463,7 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
# We've already dealt with this oid...
continue
serial
,
tid
=
self
.
_getSerialAndTid
(
oid
)
revid
=
tid
meta
=
self
.
_metadata
[
oid
+
revid
]
meta
=
self
.
_metadata
[
oid
+
tid
]
curvid
,
nvrevid
=
struct
.
unpack
(
'>8s8s'
,
meta
[:
16
])
# Make sure that the vid in the metadata record is the same as
# the vid we sucked out of the vids table.
...
...
@@ -484,7 +483,7 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
# Write the object id, live revision id, the current revision
# id (which serves as the previous revid to this transaction)
# to the commit log.
self
.
_commitlog
.
write_nonversion_object
(
oid
,
lrevid
,
rev
id
)
self
.
_commitlog
.
write_nonversion_object
(
oid
,
lrevid
,
t
id
)
# Remember to return the oid...
oids
[
oid
]
=
1
# We've now processed all the objects on the discarded version, so
...
...
@@ -534,8 +533,7 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
if
oids
.
has_key
(
oid
):
continue
serial
,
tid
=
self
.
_getSerialAndTid
(
oid
)
revid
=
tid
meta
=
self
.
_metadata
[
oid
+
revid
]
meta
=
self
.
_metadata
[
oid
+
tid
]
curvid
,
nvrevid
,
lrevid
=
struct
.
unpack
(
'>8s8s8s'
,
meta
[:
24
])
# Our database better be consistent.
if
curvid
<>
svid
:
...
...
@@ -548,7 +546,7 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
if
not
dest
:
nvrevid
=
ZERO
self
.
_commitlog
.
write_moved_object
(
oid
,
dvid
,
nvrevid
,
lrevid
,
rev
id
)
oid
,
dvid
,
nvrevid
,
lrevid
,
t
id
)
# Remember to return the oid...
oids
[
oid
]
=
1
# Now that we're done, we can discard this version
...
...
@@ -567,8 +565,7 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
try
:
# Let KeyErrors percolate up
serial
,
tid
=
self
.
_getSerialAndTid
(
oid
)
revid
=
tid
vid
=
self
.
_metadata
[
oid
+
revid
][:
8
]
vid
=
self
.
_metadata
[
oid
+
tid
][:
8
]
if
vid
==
ZERO
:
# Not in a version
return
''
...
...
@@ -596,11 +593,10 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
# Get the current revid for the object. As per the protocol, let
# any KeyErrors percolate up.
serial
,
tid
=
self
.
_getSerialAndTid
(
oid
)
revid
=
tid
# Get the metadata associated with this revision of the object.
# All we really need is the vid, the non-version revid and the
# pickle pointer revid.
rec
=
self
.
_metadata
[
oid
+
rev
id
]
rec
=
self
.
_metadata
[
oid
+
t
id
]
vid
,
nvrevid
,
lrevid
=
struct
.
unpack
(
'>8s8s8s'
,
rec
[:
24
])
if
lrevid
==
DNE
:
raise
KeyError
,
'Object does not exist'
...
...
@@ -1060,15 +1056,14 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
# the transaction records backwards until we find enough records.
history
=
[]
serial
,
tid
=
self
.
_getSerialAndTid
(
oid
)
revid
=
tid
# BAW: Again, let KeyErrors percolate up
while
len
(
history
)
<
size
:
# Some information comes out of the revision metadata...
vid
,
nvrevid
,
lrevid
,
previd
=
struct
.
unpack
(
'>8s8s8s8s'
,
self
.
_metadata
[
oid
+
rev
id
])
'>8s8s8s8s'
,
self
.
_metadata
[
oid
+
t
id
])
# ...while other information comes out of the transaction
# metadata.
txnmeta
=
self
.
_txnMetadata
[
rev
id
]
txnmeta
=
self
.
_txnMetadata
[
t
id
]
userlen
,
desclen
=
struct
.
unpack
(
'>II'
,
txnmeta
[
1
:
9
])
user
=
txnmeta
[
9
:
9
+
userlen
]
desc
=
txnmeta
[
9
+
userlen
:
9
+
userlen
+
desclen
]
...
...
@@ -1082,7 +1077,7 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
else
:
retvers
=
self
.
_versions
[
vid
]
# The HistoryEntry object
d
=
{
'time'
:
TimeStamp
(
rev
id
).
timeTime
(),
d
=
{
'time'
:
TimeStamp
(
t
id
).
timeTime
(),
'user_name'
:
user
,
'description'
:
desc
,
'serial'
:
serial
,
...
...
@@ -1095,7 +1090,7 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
# revision, stopping when we've reached the end.
if
previd
==
ZERO
:
break
serial
=
rev
id
=
previd
serial
=
t
id
=
previd
return
history
finally
:
self
.
_lock_release
()
...
...
@@ -1119,12 +1114,11 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
reachables
[
oid
]
=
1
# Get the pickle data for the object's current version
serial
,
tid
=
self
.
_getSerialAndTidMissingOk
(
oid
)
revid
=
tid
if
revid
is
None
:
if
tid
is
None
:
# BAW: how can this happen?! This means that an object is
# holding references to an object that we know nothing about.
continue
lrevid
=
self
.
_metadata
[
oid
+
rev
id
][
16
:
24
]
lrevid
=
self
.
_metadata
[
oid
+
t
id
][
16
:
24
]
pickle
=
self
.
_pickles
[
oid
+
lrevid
]
refdoids
=
[]
referencesf
(
pickle
,
refdoids
)
...
...
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