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