[Zodb-checkins] SVN: ZODB/trunk/src/ s/register_oid/register_oids/
-- support more than 1 oid per call.
Tim Peters
tim.one at comcast.net
Mon Aug 23 14:46:31 EDT 2004
Log message for revision 27231:
s/register_oid/register_oids/ -- support more than 1 oid per call.
Changed:
U ZODB/trunk/src/ZODB/FileStorage/fsoids.py
U ZODB/trunk/src/ZODB/tests/testfsoids.py
U ZODB/trunk/src/scripts/fsoids.py
-=-
Modified: ZODB/trunk/src/ZODB/FileStorage/fsoids.py
===================================================================
--- ZODB/trunk/src/ZODB/FileStorage/fsoids.py 2004-08-23 18:15:25 UTC (rev 27230)
+++ ZODB/trunk/src/ZODB/FileStorage/fsoids.py 2004-08-23 18:46:30 UTC (rev 27231)
@@ -35,7 +35,7 @@
"""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_oids(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 @@
# in this mapping.
self.oid2name = {}
- def register_oid(self, oid):
+ def register_oids(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.
"""
- if isinstance(oid, str):
- assert len(oid) == 8
- else:
- oid = p64(oid)
- self.oids[oid] = 0
+ for oid in oids:
+ if isinstance(oid, str):
+ assert len(oid) == 8
+ else:
+ oid = p64(oid)
+ self.oids[oid] = 0 # 0 revisions seen so far
def _msg(self, oid, tid, *args):
args = map(str, args)
Modified: ZODB/trunk/src/ZODB/tests/testfsoids.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/testfsoids.py 2004-08-23 18:15:25 UTC (rev 27230)
+++ ZODB/trunk/src/ZODB/tests/testfsoids.py 2004-08-23 18:46:30 UTC (rev 27231)
@@ -38,9 +38,9 @@
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_oids(0x123456)
+>>> t.register_oids(1)
+>>> t.register_oids(0)
>>> t.run()
>>> t.report()
oid 0x00 <unknown> 0 revisions
@@ -57,7 +57,7 @@
>>> db = ZODB.DB(st) # yes, that creates a root object!
>>> t = Tracer(path)
->>> t.register_oid(0); t.register_oid(1)
+>>> t.register_oids(0, 1)
>>> t.run(); t.report() #doctest: +ELLIPSIS
oid 0x00 persistent.mapping.PersistentMapping 1 revision
tid 0x... offset=4 ...
@@ -83,7 +83,7 @@
>>> txn.get().note('added an OOBTree')
>>> txn.get().commit()
>>> t = Tracer(path)
->>> t.register_oid(0); t.register_oid(1)
+>>> t.register_oids(0, 1)
>>> t.run(); t.report() #doctest: +ELLIPSIS
oid 0x00 persistent.mapping.PersistentMapping 2 revisions
tid 0x... offset=4 ...
@@ -123,7 +123,7 @@
>>> 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_oids(*range(3))
>>> t.run(); t.report() #doctest: +ELLIPSIS
oid 0x00 persistent.mapping.PersistentMapping 2 revisions
tid 0x... offset=4 ...
Modified: ZODB/trunk/src/scripts/fsoids.py
===================================================================
--- ZODB/trunk/src/scripts/fsoids.py 2004-08-23 18:15:25 UTC (rev 27230)
+++ ZODB/trunk/src/scripts/fsoids.py 2004-08-23 18:46:30 UTC (rev 27231)
@@ -68,7 +68,7 @@
if path is not None:
for line in open(path):
as_int = int(line, 0)
- c.register_oid(as_int)
+ c.register_oids(as_int)
if not c.oids:
raise ValueError("no oids specified")
c.run()
More information about the Zodb-checkins
mailing list