Storing and Using Object references
Hello all, i have a question and I hope someone can point me in the right direction to solve it. I need one zope object to hold a reference to another zope object so the first object can call methods of the second object. oh, these are python classes. Example: object 1 is : /container1/container1a/item1 object 2 is : /container2/container2a/item1 object1 needs to hold a reference to object2. I'm really stuck on how to store and access object2 from object1. any pointers? Tom Jenkins devis - Development InfoStructure http://www.devis.com
If you call /container1/container1a/container2/container2a/item1, you can call methods on anything in the path... You could access it through dtml from 1->2 as <dtml-with "container1.container1a.item1"><dtml-call method></dtml-with> You could get object2 in using getItem... -- Andy McKay. ----- Original Message ----- From: "Tom Jenkins" <tjenkins@devis.com> To: <zope@zope.org> Sent: Wednesday, January 10, 2001 8:48 PM Subject: [Zope] Storing and Using Object references
Hello all, i have a question and I hope someone can point me in the right direction to solve it. I need one zope object to hold a reference to another zope object so the first object can call methods of the second object. oh, these are python classes.
Example: object 1 is : /container1/container1a/item1 object 2 is : /container2/container2a/item1 object1 needs to hold a reference to object2. I'm really stuck on how to store and access object2 from object1.
any pointers?
Tom Jenkins devis - Development InfoStructure http://www.devis.com
_______________________________________________ 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 )
Tom Jenkins wrote:
Hello all, i have a question and I hope someone can point me in the right direction to solve it. I need one zope object to hold a reference to another zope object so the first object can call methods of the second object. oh, these are python classes.
Example: object 1 is : /container1/container1a/item1 object 2 is : /container2/container2a/item1 object1 needs to hold a reference to object2. I'm really stuck on how to store and access object2 from object1.
any pointers?
I think what you're looking for is getPhysicalPath() and unrestrictedTraverse(). Store object2.getPhysicalPath(), which returns a tuple, in object1. To find object2 again, call object1.unrestrictedTraverse(stored_physical_path). Note that this only works in Zope 2.2.x+. Shane
participants (3)
-
Andy McKay -
Shane Hathaway -
Tom Jenkins