[ZODB-Dev] Tool for exploring raw ZODB data

Christian Reis kiko@async.com.br
Fri, 14 Feb 2003 23:02:54 -0200


On Fri, Feb 14, 2003 at 05:56:03PM -0500, Jeff Sasmor wrote:
> "Christian Reis" <kiko@async.com.br> wrote:
> 
> >Looks cool, but I have a question. How are the objects organized into
> >paths, as this seems to be hardcoded into the application. Was it
> >designed for something like Zope uses?
> 
> No, actually it doesn't matter what system you're using; this works
> at too low a level to care. The ZODB is the same no matter
> what's 'above' it. Even in Zope, there's a path from the Root Folder
> thru folders, etc.

I think it *does* matter, or else this would work with my ZODB files :-)
No, honestly, let me understand if there's an assumption being made of
if the ZODB has changed enough to break things here.

(A note; I really don't get what redir_* are at all! My mind must be
toast from my thesis work this week :-/ )

We have:

        obj = getObjectDirect(path,OPath,redir_info)
        if obj:
            for k,v in obj.items():

However, the obj I get back from *my* database isn't a dictionary; it's
a pretty deep tuple. The funny part is that I *am* asking for a mapping
(I'm pulling root['Sequences'] which is a BTree). Hmmm. Does this mean
this code is assuming we're going to pull a PersistentMapping and not a
BTree back? Hmm! Here's my tuple; it's pretty deep, but at the bottom it
contains a set of tuples containing

    (key, oid, module, klass)

(((('Companies',
    ('\x00\x00\x00\x00\x00\x01>\xce',
     ('IndexedCatalog.Catalog', 'Catalog')),
    'SOProducts',
    ('\x00\x00\x00\x00\x00\x01>\xd8',
     ('IndexedCatalog.Catalog', 'Catalog')),

    [ snip bunch of boring objects ]
     
    'SOrders',
    ('\x00\x00\x00\x00\x00\x01>\xda',
     ('IndexedCatalog.Catalog', 'Catalog')),
    'ThirdParties',
    ('\x00\x00\x00\x00\x00\x01>\xdb',
     ('IndexedCatalog.Catalog', 'Catalog'))),),),)

This causes an exception to be raised since (of course) tuples don't
have an items() method. Hmmm; so it seems that getObjectDirect() isn't
pulling out an object, but a tuple that represents what it holds. I
think.

What I don't understand, truly, is *what* this tuple is. Where does this
bizarre format come from?

> So you can see that this tool is actually platform independent.
> Just think of the + as a '.' or a '/'.

I still don't understand how this object traversal should work. Does
this assume that everything from the root object onwards is either an
object or a PersistentMapping? And BTrees don't work as expected?

> It wasn't designed for Zope, but I think if you're developing
> a Zope app it might be cool to use this to see if you have

I'm not; this is hardcode independent ZODB usage :)

> the data in the ZODB that you _think_ you have. Perhaps
> it would be handy when debugging unusual problems. It's
> also instructive if you're trying to understand how this
> layer of the ZODB works.

Yeah, I found it to be *really* cool, but I'm still poring through the
code to get a hang for it.

Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL