[ZODB-Dev] _p_jar magic stopped working

Ross Boylan RossBoylan@stanfordalumni.org
Tue, 6 Aug 2002 17:12:29 -0700


Awhile ago someone (I think Jim Fulton--thanks again) gave me a little
trick pull a globally accessible object out of the db, as used in the
following code: 

_masterName = "People-Master"

def getMasterFor(object, edressList=None):
    "Return master <EMailList> relative to argument"
    # argument must be persistent
    # WARNING: Low level implementation dependency
    db = object._p_jar.db
    print type(db), dir(db)
    master = db.get(_masterName)
    if master == None:
        if edressList == None:
            edressList = EdressList.getMasterFor(object)
        master = People(edressList)
        db[_masterName] = master
    return master

object is just any random persistent object so I can get a handle to
the db.

When I try this in Zope 2.5.1, it fails on the db.get, with 
Error Type: AttributeError
Error Value: get

Further, the debugging code above shows that db is now of type
'instance method', which is not exactly what I was aiming for!

Can anyone tell me what's changed and what I need to do?

Hmm, in this case object was created earlier in the same
transaction--could that be the trouble?

My apologies if this is the wrong list; the description says it's all
about ZODB, though the title sort of implies it's only for development
of same.  The question seemed better here than the general list.

To explain what I'm trying to do substantively: I want to use the same
db/connection/ etc that Zope is using, and stuff an object in a well
known key.

This is motivated by two concerns: first, I really want the data to be
global.  Second, I may eventually want it to be accessible by
processes running outside of Zope (e.g., a mail handler)--though I
believe I would need to go to ZEO for multiple processes to access the
db.  If you have any wisdom on that, I'd love to hear it too.

Thanks.