[ZPT] Re: a little more on scripts execution

Jim Fulton jim@zope.com
Mon, 12 Aug 2002 09:56:02 -0400


I'm coming in on this a bit late ...

Dieter Maurer wrote:
> Michal Kurowski writes:
>  > I've got a couple of tables and I access them with a single script
>  > using "lists of dictionaries".
>  > Then I render them in ZPT. 
>  > What is needed is to pass those sql data around, for example to some
>  > scripts using links as above.
> I see two options:
> 
>   1. you explicitly pass the data around via return value and parameters

This seems, by far, to be the cleanest solution.

>   2. you put them in the "REQUEST" object

I wish I had never made this possible. It was a bit of a hack, IMO.

> Both ways are restricted to a single request processing.

Is that an issue?


>   ZSQL results are too complex to be stored in a (standard Zope 2.5) session
>   object.

But they can be cached.

>  > ...
>  > But for now I'm seeking for wizards' knowledge about  namespaces in
>  > ZPT and such.
> ZPT namespaces cannot be used to pass information from inside a
> script to the ZPT implicitly, you need to return the information
> as the scripts return value and bind it to a name in the ZPT namespace.
> 
> I am not sure whether the ZPT namespace is automatically passed to
> Python Scripts when they bind the "namespace" binding variable.
> It may be the case. You can go via an intermediate DTML object,
> if it does not work (though I do not recommend this way).

I hate the idea of passing ZPT namespaces around. If this is possible,
then I'd like to depreccate it. It smells of FORTAN COMMON blocks.

It was important for DTML subtemplates, which acted a lot like ZPT macros,
to have access to the calling template namespace. It sort of made sense to
generalize this to calling scripts, although, seeing the legacy of it,
maybe I wouldn't even support that today.

Jim

-- 
Jim Fulton           mailto:jim@zope.com       Python Powered!
CTO                  (888) 344-4332            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org