Andy - looking up 'this' in a dtml method or document won't work
unless you expose it in your python product/tag definition. I'm
talking about getting 'this' inside a dtml tag that I have defined
myself (i.e. <dtml-foobar></dtml-foobar>). If you want 'this'
available in dtml, write an external method and just return 'self'
def this(self): return self
>>>>> "Andy" == Andy McKay <[EMAIL PROTECTED]> writes:
Andy> Really? Ive looked up this and get nothing (an attribute error actually) and
Andy> its not in globals. If that would work that would be great - but a it
Andy> certainly doesnt seem to on a standard DTMLDocument / Method.
Andy> ----- Original Message -----
Andy> From: "Brett Carter" <[EMAIL PROTECTED]>
Andy> To: "Andy McKay" <[EMAIL PROTECTED]>
Andy> Cc: <[EMAIL PROTECTED]>
Andy> Sent: Tuesday, September 12, 2000 4:17 PM
Andy> Subject: Re: [Zope-dev] Custom dtml tag
>> Andy: here's what I've gleaned - in a dtml tag's render() method, you
>> get passed in self and a template dict, in my example let's call it
>> 'md'. md is essentially a stack/dictionaryish object of the *current*
>> namespace - and one of the handy things that's always around in the
>> namespace is the 'this' function, which returns the object on the top
>> of the stack.
>> Just lookup 'this', run it, and there you have a reference to the
>> calling object! Ex:
>> def render(self, md)
>> this = md.getitem('this')
>> callingObj = this()
>> return "Calling object was %s" % (callingObj.id())
>> Note I haven't tested this code. Good luck!
Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists -