[Zope] ZPT Problem

beno zope@thewebsons.com
Fri, 03 Jan 2003 09:06:36 -0400


At 11:04 AM 1/3/2003 +0100, you wrote:
>on or about, Friday, January 03, 2003, we have reason to believe that beno 
>wrote something along the lines of :
>
> > I have a python script I call from a page template. Here's the call:
>
> > <p tal:replace="structure python:here.contentMacro(template.id)" />
>
> > Here's the script:
>
> > template_id = template_id[:-4]
> > if (template_id[:-5] != 'frame')
> >   template_id = template_id + '_frame'
> > content = "<p tal:replace='here/" + template_id + 
> "_content/macros/content'
>/>>\n"
> > print content
> > return printed
>
> > If this is called from either *index.zpt* or *index_frame.zpt* it renders
> > the following code:
>
> > <p tal:replace='here/index_frame_content/macros/content' />
>
>This is (luckily ;) ) not
>the way ZPT works.

Yeah, I see the potential for abuse.

>Try this (untested code) for your script
>
>template_id = template_id[:-4]
>if (template_id[:-5] != 'frame'):
>     template_id = template_id + '_frame'
>newpath = 'here/' + template_id + '_content/macros/content'
>return newpath
>
>and change your call to :
><p tal:replace="structure python:path(here.contentMacro(template.id))" />

It rendered this:
  [('version', '1.4'), ('mode', 'html'), ('setSourceFile', 
'/viebc/en/index_frame_content'), ('startTag', ('div', 
[('metal:define-macro', 'content', 'metal')])), ('rawtextColumn', ('\n<body 
bgcolor="#ffffff">\ntest\n</body>\n</div>', 6))]

What I want is this:
<body bgcolor="#ffffff">
test
</body>

The file is located in /viebc/en/index_frame_content as described above. 
What do?
TIA,
beno