[ZPT] Adding to namespace stack in ZPT
Dylan Jay
djay@avaya.com
Sun, 23 Jun 2002 10:20:27 +1000
----- Original Message -----
From: "Evan Simpson" <evan@4-am.com>
To: "Jay, Dylan" <djay@avaya.com>
Cc: <ZPT@zope.org>
Sent: Saturday, June 22, 2002 12:39 AM
Subject: Re: [ZPT] Adding to namespace stack in ZPT
> Jay, Dylan wrote:
> > This one is getting me fustrated. I want to call some DTMLMethods from a
> > template perhaps with a database result in the context (ie at the top of
the
> > namespace stack). Although I can call DTML from ZPT I can't seem to
place
> > things in the namespace stack, ZPT just uses its own namespace. For
instance
> >
> > <dtml-with "qryA()[0]">
> > <dtml-call showRow>
> > </dtml-with>
>
> ZPTs deliberately have nothing like the DTML namespace, although they
> can deal with it if you pass it explicitly. I presume that 'showRow' is
> the ZPT, here?
No, the other way round. showRow is DTML and I don't want to convert it. I
want to do the above in ZPT.
> > How do I replace that (without rewriting showRow?
>
> There might be a really roundabout clever hack to do that, but is it
> really a requirement? The following should do what you need, if you're
> willing to touch showRow:
>
> <dtml-with "qryA()[0]">
> <dtml-call expr="showRow(ns=_)">
> </dtml-with>
Given what I said above the problem is how to get the ns from within ZPT and
how to add to it? eg
<span tal:define="row here/qryA">
<span tal:content="python:here.showRow(here, ns+row, request)"></span>
</span>
In other words how can I call a DTMLMethod from within a ZPT while still
retaining control of the namespace pased in?
or another way to solve my problem would be something like this
<span tal:definemap="here/qryA">
<span tal:content="here/showRow"></span>
</span>
where definemap is something that takes all the keys from a map or object
and makes them into variables in the ZPT namespace. This would be a direct
replacement for dtml-with and would also solve my problem.
> ...and change showRow to use "options/ns/whatever" to access the
> 'whatever' value in the namespace.
>
> Cheers,
>
> Evan @ 4-am
>