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

Dieter Maurer dieter@handshake.de
Wed, 28 May 2003 23:11:47 +0200


Jean-Francois.Doyon@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