Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
Commits
c35f03d1
Commit
c35f03d1
authored
Aug 23, 2004
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
s/register_oid/register_oids/ -- support more than 1 oid per call.
parent
5bf75c18
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
src/ZODB/FileStorage/fsoids.py
src/ZODB/FileStorage/fsoids.py
+10
-9
src/ZODB/tests/testfsoids.py
src/ZODB/tests/testfsoids.py
+6
-6
src/scripts/fsoids.py
src/scripts/fsoids.py
+1
-1
No files found.
src/ZODB/FileStorage/fsoids.py
View file @
c35f03d1
...
...
@@ -35,7 +35,7 @@ class Tracer(object):
"""Trace all occurrences of a set of oids in a FileStorage.
Create passing a path to an existing FileStorage.
Call register_oid
(
) one or more times to specify which oids to
Call register_oid
s(oid, ...
) one or more times to specify which oids to
investigate.
Call run() to do the analysis. This isn't swift -- it has to read
every byte in the database, in order to find all references.
...
...
@@ -62,21 +62,22 @@ class Tracer(object):
# in this mapping.
self
.
oid2name
=
{}
def
register_oid
(
self
,
oid
):
def
register_oid
s
(
self
,
*
oids
):
"""
Declare that
an oid is
"interesting".
Declare that
oids (0 or more) are
"interesting".
The
oid can be given as a native 8-byte string, or as an
An
oid can be given as a native 8-byte string, or as an
integer.
Info will be gathered about all appearances of this oid in the
entire database, including references.
"""
for
oid
in
oids
:
if
isinstance
(
oid
,
str
):
assert
len
(
oid
)
==
8
else
:
oid
=
p64
(
oid
)
self
.
oids
[
oid
]
=
0
self
.
oids
[
oid
]
=
0
# 0 revisions seen so far
def
_msg
(
self
,
oid
,
tid
,
*
args
):
args
=
map
(
str
,
args
)
...
...
src/ZODB/tests/testfsoids.py
View file @
c35f03d1
...
...
@@ -38,9 +38,9 @@ Create an empty FileStorage.
There's not a lot interesting in an empty DB!
>>> t = Tracer(path)
>>> t.register_oid(0x123456)
>>> t.register_oid(1)
>>> t.register_oid(0)
>>> t.register_oid
s
(0x123456)
>>> t.register_oid
s
(1)
>>> t.register_oid
s
(0)
>>> t.run()
>>> t.report()
oid 0x00 <unknown> 0 revisions
...
...
@@ -57,7 +57,7 @@ Create a root object and try again:
>>> db = ZODB.DB(st) # yes, that creates a root object!
>>> t = Tracer(path)
>>> t.register_oid
(0); t.register_oid(
1)
>>> t.register_oid
s(0,
1)
>>> t.run(); t.report() #doctest: +ELLIPSIS
oid 0x00 persistent.mapping.PersistentMapping 1 revision
tid 0x... offset=4 ...
...
...
@@ -83,7 +83,7 @@ Let's add a BTree and try again:
>>> txn.get().note('added an OOBTree')
>>> txn.get().commit()
>>> t = Tracer(path)
>>> t.register_oid
(0); t.register_oid(
1)
>>> t.register_oid
s(0,
1)
>>> t.run(); t.report() #doctest: +ELLIPSIS
oid 0x00 persistent.mapping.PersistentMapping 2 revisions
tid 0x... offset=4 ...
...
...
@@ -123,7 +123,7 @@ One more, storing a reference in the BTree back to the root object:
>>> txn.get().note('circling back to the root')
>>> txn.get().commit()
>>> t = Tracer(path)
>>> t.register_oid
(0); t.register_oid(1); t.register_oid(2
)
>>> t.register_oid
s(*range(3)
)
>>> t.run(); t.report() #doctest: +ELLIPSIS
oid 0x00 persistent.mapping.PersistentMapping 2 revisions
tid 0x... offset=4 ...
...
...
src/scripts/fsoids.py
View file @
c35f03d1
...
...
@@ -68,7 +68,7 @@ def main():
if
path
is
not
None
:
for
line
in
open
(
path
):
as_int
=
int
(
line
,
0
)
c
.
register_oid
(
as_int
)
c
.
register_oid
s
(
as_int
)
if
not
c
.
oids
:
raise
ValueError
(
"no oids specified"
)
c
.
run
()
...
...
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