How to call a method on another object in DTML
Hello, I am trying to render the index_html method of another object in a new "wrapper" object. Normally you just do a <dtml-var object> and Zope will find the object. But what if the object is far away in another hierarchy and I want to render it (not call its index_html method on my object!) Thanks, Pieter -- ----------------------------- Pieter Claassen pieter@openauth.co.uk http://www.openauth.co.uk OpenAuth Tel: 01344 390530 DDI: 01344 390630/390631 Fax number: 01344 390700 Mobile: 0776 665 6924 Highview House Charles Square Bracknell Berkshire RG12 1DF TERMS AND CONDITIONS (i)The information contained in this email and attachments is only intended for the addressed recipient(s) and may not be distributed or viewed by any other party without the explicit consent of the sender. If you have received this message by accident, please contact Pieter Claassen (pieter@openauth.co.uk) and destroy any electronic or physical copies of the information contained in it, immediately. (ii)This email is not certified to be virus free and OpenAuth accepts no liability for losses arising from you receiving this email. (iii)Any digital signatures (if present) used to authenticate this email, only serves to allow you to verify the originating email address of the sender and should not be relied upon to prove identity or base financial transactions on, unless the Certificate Practice Statement that the signature references, explicitly states differently. (iv)This email may be subjected to further terms and conditions as published on the company website at http://www.openauth.co.uk. If you need to rely on the information contained in this email in any way, then you should read those terms and conditions to understand how much you can trust the information in this email. (v)OpenAuth retains the copyright on any relevant material that is included in this email.
pieter claassen wrote:
I am trying to render the index_html method of another object in a new "wrapper" object.
Normally you just do a <dtml-var object> and Zope will find the object.
But what if the object is far away in another hierarchy and I want to render it (not call its index_html method on my object!)
It is a bit unclear what you are trying to do. But to get to the object, you need a path to it. Just use the first objectManager that they both share as the root. <dtml-var "path.to.some.object.index_html()"> To give it a new context, you can pass it "this()" as an argument ( a "mapping dictionary") <dtml-var "path.to.some.object.index_html(this())"> You can even hand it some named parameters also: <dtml-var "path.to.some.object.index_html(this(), title_or_id='Some New Title')"> The values in the dtml page will be looked up in this order: named parameters -> mapping dictionary -> the objects original context regards Max M
pieter claassen wrote at 2003-3-17 10:55 +0000:
But what if the object is far away in another hierarchy and I want to render it (not call its index_html method on my object!)
You use "restrictedTraverse" to locate the object.... Dieter
participants (3)
-
Dieter Maurer -
Max M -
pieter claassen