[Zope-dev] Custom dtml tag
Martijn Pieters
mj@digicool.com
Tue, 12 Sep 2000 20:29:17 +0200
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
-----------------------------------------------------