Commit 26c4aaeb authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

use ZODB.utils.get_pickle_metadata instead of pickle.Unpickler.

* it is faster.
* it does not require Products.
parent 88cd32df
...@@ -2,22 +2,9 @@ ...@@ -2,22 +2,9 @@
# Based on a transaction analyzer by Matt Kromer. # Based on a transaction analyzer by Matt Kromer.
import pickle
import re
import sys import sys
import types
from ZODB.FileStorage import FileStorage from ZODB.FileStorage import FileStorage
from cStringIO import StringIO from ZODB.utils import get_pickle_metadata
class FakeError(Exception):
def __init__(self, module, name):
Exception.__init__(self)
self.module = module
self.name = name
class FakeUnpickler(pickle.Unpickler):
def find_class(self, module, name):
raise FakeError(module, name)
class Report: class Report:
def __init__(self): def __init__(self):
...@@ -97,18 +84,8 @@ def analyze_trans(report, txn): ...@@ -97,18 +84,8 @@ def analyze_trans(report, txn):
analyze_rec(report, rec) analyze_rec(report, rec)
def get_type(record): def get_type(record):
try: mod, klass = get_pickle_metadata(record.data)
unpickled = FakeUnpickler(StringIO(record.data)).load()
except FakeError, err:
return "%s.%s" % (err.module, err.name)
except:
raise
classinfo = unpickled[0]
if isinstance(classinfo, types.TupleType):
mod, klass = classinfo
return "%s.%s" % (mod, klass) return "%s.%s" % (mod, klass)
else:
return str(classinfo)
def analyze_rec(report, record): def analyze_rec(report, record):
oid = record.oid oid = record.oid
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment