Re: [Zope] Getting a Handle to a ZODB object to store in another object
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. 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.) I think you would have to use something analogous to "cookies" in the stateless HTTP protocol. I.e., some sort of intermediary. How to do that, I know not. Ron
Hi all,
I would like to have an object in one folder be referenced by another object in another folder (think symlinks in UNIX) ... but I'm not sure what properties an object has that identify it's absolute location (absolute_url is a little fluffy, no?).
Anyone have any ideas on how to approach this?
Thanks in advance,
Ziniti
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
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"
Chris McDonough wrote:
What about ob.getPhysicalPath()? This is unique for every placeful Zope object. You can then resolve it back out to an object via restrictedTraverse.
I find those paths to be just as "fluffy" as absolute_url(). For example, I have the following structure: SRS11/Users/rejpz/20010115A/Sample1 Users is a folder. "rejpz" and "20010115A" are Product classes I am writing which inherit from ObjectManager. "Sample1" inherits from SimpleItem.Item. But Sample1.getPhysicalPath returns (", 'SRS11', 'Users', 'Users', 'Users', 'Sample1') Am I missing something, or is that "fluffy"?
If getPhysicalPath doesn't return the physical path, it's a bug. Can you give a reproducible test case, maybe by sending me an export of the object tree that exhibits this behavior? What Zope version is this? ----- Original Message ----- From: "John Ziniti" <jziniti@speakeasy.org> To: <chrism@zope.com> Cc: <zope@zope.org> Sent: Thursday, November 29, 2001 9:54 AM Subject: Re: [Zope] Getting a Handle to a ZODB object to store in another object
Chris McDonough wrote:
What about ob.getPhysicalPath()? This is unique for every placeful Zope object. You can then resolve it back out to an object via restrictedTraverse.
I find those paths to be just as "fluffy" as absolute_url(). For example, I have the following structure:
SRS11/Users/rejpz/20010115A/Sample1
Users is a folder. "rejpz" and "20010115A" are Product classes I am writing which inherit from ObjectManager. "Sample1" inherits from SimpleItem.Item.
But Sample1.getPhysicalPath returns
(", 'SRS11', 'Users', 'Users', 'Users', 'Sample1')
Am I missing something, or is that "fluffy"?
Chris McDonough wrote:
If getPhysicalPath doesn't return the physical path, it's a bug. Can you give a reproducible test case, maybe by sending me an export of the object tree that exhibits this behavior? What Zope version is this?
OK ... my Products were not inheriting from OFS.SimpleItem.Item, only from OFS.ObjectManager.ObjectManager, so they were not getting the getId() method properly (or something). Adding that class to the inheritance hierarchy solved the getPhysicalPath problem. Sorry for the trouble ... But is there some compelling reason that ObjectManager doesn't inherit from Item? bah ... Thanks for your time, Ziniti
participants (4)
-
Chris McDonough -
Chris McDonough -
complaw@hal-pc.org -
John Ziniti