[Zope-dev] Custom dtml tag
Andy McKay
andym@ActiveState.com
Tue, 12 Sep 2000 15:33:10 -0700
I can see how this would be useful in a situation where I dont have an
instance of self. But in this case I do, so Im not sure how this helps.
I guess you're saying once I have self I can find out what called the
function. More fiddling I guess.
----- Original Message -----
From: "Martijn Pieters" <mj@digicool.com>
To: "Andy McKay" <andym@activestate.com>
Cc: <zope-dev@zope.org>
Sent: Tuesday, September 12, 2000 11:29 AM
Subject: Re: [Zope-dev] Custom dtml tag
> On Tue, Sep 12, 2000 at 09:26:49AM -0700, Andy McKay wrote:
> > Hmm well ive found i have <TemplateDict> object and of course my self.
> > Perhaps there is a pythonism I have to research here.
> >
> > ----- Original Message -----
> > From: "Andy McKay" <andym@ActiveState.com>
> > To: <zope-dev@zope.org>
> > Sent: Monday, September 11, 2000 4:03 PM
> > Subject: [Zope-dev] Custom dtml tag
> >
> >
> > > Im playing with a custom dtml-tag along the lines of <dtm-query foo>
> > > constructs a url to a catalog query. It works fine, I would just like
to
> > > extend it a bit and for this I would need to get to the calling
object.
> > >
> > > For example, there will be a different query depending upon the object
the
> > > dtml-query tag is contained in. Does this make sense, does anyone know
the
> > > answer?
> > >
> > > Thanks in advance.
> > >
> > > --
> > > Andy McKay, Developer.
> > > ActiveState.
>
> The namespace just reflects the attributes of the current object, plus
> whatever other tags push onto that stack (such as the in tag, which pushes
> the current element of the list it iterates over on top).
>
> If you retrieve the 'this' method from the stack, and call it, it'll
> return the topmost object on the stack. It is implemented in
> SimpleItem.Item:
>
> def this(self):
> # Handy way to talk to ourselves in document templates.
> return self
>
> --
> Martijn Pieters
> | Software Engineer mailto:mj@digicool.com
> | Digital Creations http://www.digicool.com/
> | Creators of Zope http://www.zope.org/
> | ZopeStudio: http://www.zope.org/Products/ZopeStudio
> -----------------------------------------------------
>