Finding specific parent object with acquisition ?
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
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' ?
You can simply refer to self.ProductA if you inherit from SimpleItem (it includes implicit acquisition). You can also acquire the REQUEST object that way, for instance. PS. Cool, 'nother Martijn. Remeber, Martijn Faassen is The Other Martijn (even if he claims I am), I'm The Original Martijn. Not sure what we'll call you though... This has nothing to do with the Dutch conspiracy, as it doesn't exist. Nice to see another Dutch Web agency use Zope for Content Management. I never was able to convince my previous employer of the advantages, as "everyone wants Java".. -- Martijn Pieters | Software Engineer mailto:mj@zope.com | Zope Corporation http://www.zope.com/ | Creators of Zope http://www.zope.org/ ---------------------------------------------
On Wed, Aug 15, 2001 at 12:34:10PM -0400, Martijn Pieters wrote: <snip>
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 :)
<snip>
You can simply refer to self.ProductA if you inherit from SimpleItem (it includes implicit acquisition). You can also acquire the REQUEST object that way, for instance.
to be closer to your example, it would probably be regProdA = getattr(self, 'ProductA') -d -- | Dyon Balding . Software Engineer . HiringTools.Monster.com | dyon@hiringtools.com . +1 415 288 3375
You can simply refer to self.ProductA if you inherit from SimpleItem (it includes implicit acquisition). You can also acquire the REQUEST object that way, for instance.
Thanx, now I know for sure :) My last mail was a little bit long, because I wanted to be sure everybody would understand it, but I forgot the essence of my problem :) Instead of saying self.<id>, which gives me the object I want by id, I want to do something like self.getObject("Special Folder"), where I want to find the first instance of a specific type, for example the (made-up) product "Special Folder". Is this also possible finding it by acquisition?
PS. Cool, 'nother Martijn. Remeber, Martijn Faassen is The Other Martijn (even if he claims I am), I'm The Original Martijn. Not sure what we'll call you though... This has nothing to do with the Dutch conspiracy, as it doesn't exist. Well, at my company we also have three Martijn's, so it's not a dutch conspiracy, but a martijn-conspiracy :) They call me 'mart' over here, so that would be fine.
Nice to see another Dutch Web agency use Zope for Content Management. I never was able to convince my previous employer of the advantages, as "everyone wants Java".. Jeps, everyone ones java with all his disadvantages. After a review of different platforms and development tools we decided to use Zope, because the philosophy behind it and the logic it uses is brilliant! We are building a CMS on top of zope, so every coffee-lady can make her own website :)
BTW, You are working for Zope Company now? martijn jacobs eastsite www.eastsite.nl
Instead of saying self.<id>, which gives me the object I want by id, I want to do something like self.getObject("Special Folder"), where I want to find the first instance of a specific type, for example the (made-up) product "Special Folder". Is this also possible finding it by acquisition?
Ow damm. Once you understand it, it's so simpel :) if self.objectIds("Special Folder") != []: #you found a Special Folder! it's doing acquisition is this way also. Thank you for the help anyway!!!!! martijn jacobs eastsite www.eastsite.nl
participants (3)
-
Dyon Balding -
Martijn Jacobs -
Martijn Pieters