[ZPT] Content/Presentation Separation
Harry Wilkinson
harryw@nipltd.com
Thu, 25 Apr 2002 16:25:06 +0100
On Thursday 25 April 2002 4:10 pm, Florent Guillaume wrote:
> > > I think that it should work exactly the way around :
> > > URL traversal should arrive on a Python script which access data and
> > > prepares it before passing it to a Page template.
> >
> > That's the same conclusion I arrived to after a few months of usage of
> > Page Templates.
>
> I do it the dual way; my page templates start with something like:
>
> <tal:block define="global data here/displayform_getdata" />
>
> and displayform_getdata is a python script that computes all relevant
> data for the display of this page template, and returns it as a dict.
>
> The big advantage over your method is that displayform_getdata can be
> called from several different page templates, so I can factor out code
> easily.
>
> Florent
This is pretty much how I do it too. If I want to do anything to change the
data, and not just view it (assuming I don't want the fact I'm presenting
some data to change anything), I'll get the client to make an HTTP request to
a Python script, which will do its thing and then probably
response.redirect() to a page template.
Works well for me :)
Harry