Hi; 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' /> Unfortunately, this code isn't called, just rendered. I would like said macro to actually be called (of course). What have I missed? TIA, beno
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. 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))" /> this should (i hope) give you what you want, although it does not seem like a very clean solution. -- Geir Bækholt geir@funcom.com Tools/HCI-developer Tools/Billing - Product Operations Funcom Oslo
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
beno wrote at 2003-1-3 05:40 -0400:
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' /> When you want to expand a macro, you should use the attribute designed for this, that is "metal:use-macro"...
Dieter
participants (3)
-
beno -
Dieter Maurer -
Geir B�kholt