RE: [Zope-dev] dtml: "where am I? who am I?"
-----Original Message----- From: Lalo Martins [mailto:lalo@webcom.com] Sent: Wednesday, November 24, 1999 3:41 PM To: zope-dev@zope.org Subject: [Zope-dev] dtml: "where am I? who am I?"
Is there a way for a method (dtml or python, whatever) to know its location? Say:
foo (folder) +--- bar (folder) | +--- my_method (DTML|python method) +--- gee (folder) +--- index_html
if gee/index_html calls my_method, it doesn't know it's inside ``bar'' so it messes up any relative URL it spits.
I think what your looking for is the containment path of the object, not the acquisition path. If you use acquisition, you'll have to deal with the fact that the objects 'path' depends on how it is acquired. In your example, if gee/index_html called my_method, then its aq_parent is 'gee' not 'bar'. This is the correct behavior. If you want to find an objects *containment* parent, then you have to do 'object.aq_inner.aq_parent'. You cannot get 'aq_inner' from DTML, I can't think of any good reason why not, but security would have to be carefully thought out. -Michel
On Wed, Nov 24, 1999 at 04:49:30PM -0500, Michel Pelletier wrote:
if gee/index_html calls my_method, it doesn't know it's inside ``bar'' so it messes up any relative URL it spits.
I think what your looking for is the containment path of the object, not the acquisition path. If you use acquisition, you'll have to deal with the fact that the objects 'path' depends on how it is acquired. In your example, if gee/index_html called my_method, then its aq_parent is 'gee' not 'bar'. This is the correct behavior.
Yes, I get that. As I said, the real-world example is the Banner Product: root +--- BroDar (Folder) | +--- BotaoBroDar (BannerAd) +--- lalo (Folder) +--- aqtest (DTML Method) Documents under ``BroDar'' can include the button by using <dtml-var BotaoBroDar>. Works. But if something under ``lalo'' tries to include it (<dtml-var "BroDar.BotaoBroDar">), it will generate something like: <a href="BotaoBroDar/hit"><img src="BotaoBroDar"></a> which of couse won't work. I worked around this by copying the button to my folder. In the BannerFolder ZClass, I work around this by doing the Python equivalent of sed'ing the BannerAd output to convert it to something like <a href="banner/BotaoBroDar/hit"><img src="banner/BotaoBroDar"></a> (where ``banner'' is the name of the BannerFolder). But I wonder if there isn't a better way. []s, |alo +---- -- I am Lalo of deB-org. You will be freed. Resistance is futile. http://www.webcom.com/lalo mailto:lalo@webcom.com pgp key in the web page Debian GNU/Linux --- http://www.debian.org Brazil of Darkness -- http://zope.gf.com.br/BroDar
participants (2)
-
Lalo Martins -
Michel Pelletier