[Zope-dev] Finding specific parent object with acquisition ?
Martijn Jacobs
mart@eastsite.nl
Wed, 15 Aug 2001 17:08:16 +0200
Hello!
I have a question about acquisition and namespaces and how to use them in
your product code.....
Imagine you have the following structure in zope :
(ProductA is a Product derived from Folder/Objectmanager so it can hold other
objects, ProductB is a simpleitem product)
Root
|
----ProductA
|
----Folder6
|
----Folder7
|
----ProductB
|
----DTMLDoc1
OK : If I execute http://localhost/ProductA/Folder6/Folder7/DTMLDoc1 and I
put in the DTMLDoc1 this code : '<dtml-var "ProductA">' , it will look
back and it will find the ProductA instance and it will call it's index_html,
because in DTML you have a namespace where the DTML-execute code can
find 'ProductA' on a great way.
Now the following thing : I want to acquire a reference TO ProductA
IN the product code of ProductB so I will be able to execute functions from
ProductA in ProductB, for example :
class ProductB(.....)
def blah():
refProdA = self.acquire('ProductA');
(self.acquire is not a real function, only for illustration what kind of
function I would like to have in a Zope object :)
Do I have a same namespace in my Productcode (the python code of this product)
so it will acquire automaticily the reference to ProductA, for example the way
I use here above? Or do I have to program this manually by repeatly calling
the aq_parent method until I find an instance of 'ProductA' ?
thnx in advance,
martijn jacobs
eastsite