[ZPT] Nesting templates

Max Romantschuk max@provico.fi
Fri, 22 Nov 2002 07:58:03 +0200


Quoting Clemens Robbenhaar <robbenhaar@espresto.com>:
> About the 'structure' keyword: maybe look at
>  http://www.zope.org/Documentation/Books/ZopeBook/current/AppendixC.stx 
> (though it is a little hard to find the place where it is explained that
> it renders the value without escaping '<', '>', '&' ...)

OK, found it now... Had looked there aswell, but missed it somehow :)


>  > So really my question comes down to: how do I nest a template? Should I
>  > even be doing this?
> 
>  You can do this, if this home grown design/content separation is just
> good enough for You. However You do not give an example how the content
> is selected ... I assume the id of the "content" page template to be
> rendered is passed as request-parameter 'content_id'; e.g. if this is
> 'foo', You want to include /site_root/content/foo in Yout index_html.

I haven't really decided on all the pieces yet, I've been looking at lot's of 
different ways to do stuff and I'm trying to make out the best one...

I'm sure some kind of content object approach is the most scalable solution, 
but at the moment I'm looking for more of a quick and dirty solution to get me 
started... Then I'll have something to improve on ;)

 
>  The dynamic lookup should go via the 'getattr' helper function, e.g.
> 
> <span tal:define="content_page python:getattr(here.content,
> request['foo'])"
>       tal:replace="structure content_page" />
> 
> If the lookup is more complex (e.g. You might want some error handling,)
> its better done by a script called from the 'index_html'. Well, it seems
> You are already doing this, if I understand correctly ...

I'm doing it with a script yes, but so far I've had the problem that my script 
only returns the path of the object I want, not it's content... But I'll figure 
that out.

 
>  > CMF I don't wish to use at the moment though. Too complex and too rigid
> for
>  > my taste. I've looked at Kubes, but they looked too much like a kludge.
> 
>  I guess the developers of these products will appreciate Your subtle
> and informed comments very much ;->

I realize this was a but of a flame, but then again I'm willing to back up my 
opinions and don't mind being proven wrong :)

My personal goal is to come up with a solution which is a flexible as possible 
without having a huge framework that is needed to get to square one. I'm sure 
I'm not going to get anywhere with my first attempt, but doing everything 
myself ensures I learn more.


 Thanks for the help,
Max