[Zope] Getting a Handle to a ZODB object to store in another object
Chris McDonough
chrism@zope.com
Wed, 28 Nov 2001 20:25:19 -0500
What about ob.getPhysicalPath()? This is unique for every placeful Zope
object. You can then resolve it back out to an object via
restrictedTraverse.
These methods are documented in the help system and the nebulous
Interfaces wiki.
> Others (myself included) have asked this same question. To date, I've not seen
> a satisfactory answer. Most object databases provide a unique identifier (an
> oid) to a given object. That reference can be stored in other objects for use
> when necessary. Good object databases are capable of establishing relationships
> between objects that are maintained. To my knowledge, Zope doesn't work that
> way. Instead, it uses the URL as a pseudo oid.
I think you actually mean the physical path. The URL of an object can
change as a result of virtual hosting, but an object's physical path
never changes unless you move it.
> This has both good and bad
> points. URL use is handy for web integration, but you give up the standard oid
> paradigm and is another reason why Zope is hard to grok. (But it is one of the
> reasons why Zope is so justly admired.)
Note that Zope is just Python, and as such, you can also use object
references in unrestricted code for the same purpose, e.g.:
ref = Folder1.foo
Folder2.bar = ref
This is a facility that is not exposed to unrestricted code for security
reasons, but it definnitely exists. It's how Zope works. ;-)
--
Chris McDonough Zope Corporation
http://www.zope.org http://www.zope.com
"Killing hundreds of birds with thousands of stones"