Hello, I have a few products that use DTML rendering by simply using the HTML function imported from Globals ... This works great, and is trivial and simple to use. 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. Here's what I had up until now, that I'd like to switch from DTML to ZPT: # Monkey patch to add DTML rendering and Properties to the CMF Document type (Effectively making it a CMF DTML Document) originalCookedBody = Document.CookedBody originalManageOptions = Document.manage_options def CookedBody(self, stx_level=None, setlevel=0): # First, run the original cookedbody = originalCookedBody(self, stx_level=None, setlevel=0) # Then, if the document is HTML, run it through the DTML rendering engine if ( self.text_format == 'html' ): cookedbody = apply(HTML(self.text), (self, self.REQUEST)) return cookedbody Document.CookedBody = CookedBody Document.manage_options = ( originalManageOptions + PropertyManager.manage_options ) This is really simple, and works great for my needs. I'd like to be able to do something similar, but with ZPT. Anyone know of a ZPT equivalent to HTML() ? Or any other similarly simple way of doing it ? Any help would be greatly appreciated! Thanks, Jean-François Doyon Internet Service Development and Systems Support GeoAccess Division Canadian Center for Remote Sensing Natural Resources Canada http://atlas.gc.ca Phone: (613) 992-4902 Fax: (613) 947-2410
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
participants (2)
-
Dieter Maurer -
Jean-Francois.Doyon@CCRS.NRCan.gc.ca