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
cd4eecf0
Commit
cd4eecf0
authored
Jun 14, 2001
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a real (and tested!) implementation of the history() method.
parent
837fd723
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
10 deletions
+102
-10
lib/python/BDBStorage/BDBFullStorage.py
lib/python/BDBStorage/BDBFullStorage.py
+51
-5
lib/python/BDBStorage/Full.py
lib/python/BDBStorage/Full.py
+51
-5
No files found.
lib/python/BDBStorage/BDBFullStorage.py
View file @
cd4eecf0
...
...
@@ -4,7 +4,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support
undo or versioning.
"""
__version__
=
'$Revision: 1.2
3
$'
[
-
2
:][
0
]
__version__
=
'$Revision: 1.2
4
$'
[
-
2
:][
0
]
import
struct
import
time
...
...
@@ -832,12 +832,58 @@ class Full(BerkeleyBase):
c
.
close
()
self
.
_lock_release
()
def
history
(
self
,
oid
,
version
=
None
,
length
=
1
,
filter
=
None
):
# FIXME
def
history
(
self
,
oid
,
version
=
None
,
size
=
1
,
filter
=
None
):
self
.
_lock_acquire
()
try
:
tid
=
self
.
_current
[
oid
]
finally
:
self
.
_lock_release
()
# Find the vid for the version
if
version
is
None
:
tvid
=
None
version
=
''
elif
version
==
''
:
tvid
=
0
else
:
# BAW: for now, let KeyErrors percolate up
tvid
=
self
.
_vids
[
version
]
# Start with the most recent revision of the object, then search
# the transaction records backwards finding revisions in the
# selected version.
history
=
[]
revid
=
self
.
_serials
[
oid
]
# BAW: Again, let KeyErrors percolate up
while
len
(
history
)
<
size
:
vid
,
nvrevid
,
lrevid
,
previd
=
struct
.
unpack
(
'>8s8s8s8s'
,
self
.
_metadata
[
oid
+
revid
])
if
tvid
is
None
or
vid
==
ZERO
or
tvid
==
vid
:
# Get transaction metadata, which we need to fill in the
# appropriate HistoryEntry slots.
txnmeta
=
self
.
_txnMetadata
[
revid
]
userlen
,
desclen
=
struct
.
unpack
(
'>II'
,
txnmeta
[
1
:
9
])
user
=
txnmeta
[
9
:
9
+
userlen
]
desc
=
txnmeta
[
9
+
userlen
:
9
+
userlen
+
desclen
]
# Now get the pickle size
data
=
self
.
_pickles
[
oid
+
lrevid
]
# Create a HistoryEntry structure, which turns out to be a
# dictionary with some specifically named entries (BAW:
# although this poorly documented).
if
vid
==
ZERO
:
retvers
=
''
else
:
retvers
=
version
d
=
{
'time'
:
TimeStamp
(
revid
).
timeTime
(),
'user_name'
:
user
,
'description'
:
desc
,
'serial'
:
revid
,
'version'
:
retvers
,
'size'
:
len
(
data
),
}
if
filter
is
None
or
filter
(
d
):
history
.
append
(
d
)
if
previd
==
ZERO
:
break
revid
=
previd
return
history
finally
:
self
.
_lock_release
()
def
_zaprevision
(
self
,
key
,
referencesf
):
# Delete the metadata record pointed to by the key, decrefing the
...
...
lib/python/BDBStorage/Full.py
View file @
cd4eecf0
...
...
@@ -4,7 +4,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support
undo or versioning.
"""
__version__
=
'$Revision: 1.2
3
$'
[
-
2
:][
0
]
__version__
=
'$Revision: 1.2
4
$'
[
-
2
:][
0
]
import
struct
import
time
...
...
@@ -832,12 +832,58 @@ class Full(BerkeleyBase):
c
.
close
()
self
.
_lock_release
()
def
history
(
self
,
oid
,
version
=
None
,
length
=
1
,
filter
=
None
):
# FIXME
def
history
(
self
,
oid
,
version
=
None
,
size
=
1
,
filter
=
None
):
self
.
_lock_acquire
()
try
:
tid
=
self
.
_current
[
oid
]
finally
:
self
.
_lock_release
()
# Find the vid for the version
if
version
is
None
:
tvid
=
None
version
=
''
elif
version
==
''
:
tvid
=
0
else
:
# BAW: for now, let KeyErrors percolate up
tvid
=
self
.
_vids
[
version
]
# Start with the most recent revision of the object, then search
# the transaction records backwards finding revisions in the
# selected version.
history
=
[]
revid
=
self
.
_serials
[
oid
]
# BAW: Again, let KeyErrors percolate up
while
len
(
history
)
<
size
:
vid
,
nvrevid
,
lrevid
,
previd
=
struct
.
unpack
(
'>8s8s8s8s'
,
self
.
_metadata
[
oid
+
revid
])
if
tvid
is
None
or
vid
==
ZERO
or
tvid
==
vid
:
# Get transaction metadata, which we need to fill in the
# appropriate HistoryEntry slots.
txnmeta
=
self
.
_txnMetadata
[
revid
]
userlen
,
desclen
=
struct
.
unpack
(
'>II'
,
txnmeta
[
1
:
9
])
user
=
txnmeta
[
9
:
9
+
userlen
]
desc
=
txnmeta
[
9
+
userlen
:
9
+
userlen
+
desclen
]
# Now get the pickle size
data
=
self
.
_pickles
[
oid
+
lrevid
]
# Create a HistoryEntry structure, which turns out to be a
# dictionary with some specifically named entries (BAW:
# although this poorly documented).
if
vid
==
ZERO
:
retvers
=
''
else
:
retvers
=
version
d
=
{
'time'
:
TimeStamp
(
revid
).
timeTime
(),
'user_name'
:
user
,
'description'
:
desc
,
'serial'
:
revid
,
'version'
:
retvers
,
'size'
:
len
(
data
),
}
if
filter
is
None
or
filter
(
d
):
history
.
append
(
d
)
if
previd
==
ZERO
:
break
revid
=
previd
return
history
finally
:
self
.
_lock_release
()
def
_zaprevision
(
self
,
key
,
referencesf
):
# Delete the metadata record pointed to by the key, decrefing the
...
...
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