[Zope] ZPT equivalent to the global HTML() ?

Jean-Francois.Doyon at CCRS.NRCan.gc.ca Jean-Francois.Doyon at CCRS.NRCan.gc.ca
Thu Aug 7 12:05:58 EDT 2003


Hello,

This works great! Now I have a funny bit of a problem though, not a big deal
, but a nice to have.

I have a template like this:

<html metal:use-macro="here/main_template/macros/master">

<p metal:fill-slot="main">

<span tal:replace="structure here/CookedBody" />

</p>

</html>

(CookedBody is extended to render ZPT, as suggested).

The problem now is that the ZPT/TAL/TALES is evaluated in it's own world,
seperatly from the main_template, which tal:define's variables I'd like to
use inside CookedBody/EditableBody code (i.e. main_template has <html
tal:define="variable expression">, but that variable isn't accessible when
CookedBody is rendrered)

Is this possible?

Another way to put it: Would it be possible to get the tal:replace to
actually pt() render the content of the returned structure ? This way I
could skip making the Document ZPT aware altogether (One less Monkey Patch),
AND I'd have access to my variables (less repeated method calls) ...

Any insight on how to accomplish something like this would be greatly
appreciated!

Thanks,
J.F.

-----Original Message-----
From: Dieter Maurer [mailto:dieter at handshake.de]
Sent: Wednesday, May 28, 2003 5:12 PM
To: Jean-Francois.Doyon at CCRS.NRCan.gc.ca
Cc: zope at zope.org
Subject: Re: [Zope] ZPT equivalent to the global HTML() ?


Jean-Francois.Doyon at CCRS.NRCan.gc.ca wrote at 2003-5-27 12:14 -0400:
 > Now, I'm thinking of switching to using ZPT's, but am having a harder
time
 > figuring out exactly what function/method I should use ... there's
 > pt_render, but that's a method that expects an object of the proper class
to
 > be passed (I think?) ... Which doesn't really work in my case ... I'd
like
 > to be able to simply feed the "text" to a function, along with a context,
 > REQUEST object, or something like that, and get the results.

Its a bit more complex with ZPT than with DTML because a
PageTemplate uses context from acquisition while all context must
be explicitly passed in to DTML.

It looks somehow like:

   from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate

   pt= ZopePageTemplate('',template_source,content_type).__of__(context)
   rendered= pt() # render it


Dieter



More information about the Zope mailing list