[ZPT] Moving scripts to center stage
Wade Leftwich
wade@lightlink.com
Thu, 31 May 2001 16:41:00 -0400
> From: Evan Simpson [mailto:evan@digicool.com]
> Sent: Thursday, May 31, 2001 4:21 PM
>
> Hard to say; What is this 'pagedict' object that would you add to
> 'here'? Is it a container for the sort of data for which people have
> suggested adding PropertySheets to ZPT?
>
No, my understanding of PropertySheets is that they would contain data that
is static for the template. Same thing as if you just added properties to
the folder that contains the template, then referred to
"container/myproperty". Or could PropertySheets be assigned to from 'here',
or 'container'?
The 'pagedict' (perhaps an unfortunate name) idea is to put all the
instance-specific data inside one dictionary, so you're less likely to
collide with vars in REQUEST or wherever.
Right now, when I call a script at the top of my template, I say:
<span tal:define="global pagedict container/myscript"/>. Pagedict might look
like this:
{'title':'This Just In', 'Dateline':<DateTime instance at 12345>,
'tblrow':<r instance at cd6345789>}
What I'm hunting for is a simple way to call the template from the script.
So newscript might go:
... # put some data in pagedict
req = context.REQUEST
req.set('pagedict', pagedict)
return container.newtemplate(container.newtemplate, req)
And the top of newtemplate might say:
<span tal:define="global pagedict here/pagedict | request/pagedict |
python:{}"/>
BUT. If it's possible for newscript to add some objects directly to
newtemplate's "here", then maybe that would be simpler.
-- Wade
P.S. ZPT's have "here" and Python scripts have "context". They seem like
they're much of a muchness, despite the different names. Is that true?