tags:

views:

65

answers:

1

Every Zope object has it's own unique id ( _p_oid ).

To convert it into integer value:

from Shared.DC.xml.ppml import u64 as decodeObjectId
oid = decodeObjectId(getattr(<Object instance>, '_p_oid'))

Is it possible to get object itself having it's _p_oid?

I tried this:

from ZODB.utils import p64
object = <RootObject instance>._p_jar[p64(oid)]

But it seems it's a wrong way because after getting object I can't change any property and object.absolute_url() returns empty string.

A: 

This should work, as long as the class of the object you're trying to load is available in the Python environment, and as long as your oid isn't from another database mounted somewhere within the root.

Can you describe the way in which this is failing to work for you?

See whether the following works (it should get the root object, which has _p_oid == 0):

>>> object = root_obj._p_jar[p64(0)]
David Glick