[Zope] ZPT equivalent to the global HTML() ?
Jean-Francois.Doyon@CCRS.NRCan.gc.ca
Jean-Francois.Doyon@CCRS.NRCan.gc.ca
Tue, 27 May 2003 12:14:52 -0400
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)
=20
originalCookedBody =3D Document.CookedBody
originalManageOptions =3D Document.manage_options
=20
def CookedBody(self, stx_level=3DNone, setlevel=3D0):
# First, run the original
cookedbody =3D originalCookedBody(self, stx_level=3DNone, =
setlevel=3D0)
# Then, if the document is HTML, run it through the DTML =
rendering
engine
if ( self.text_format =3D=3D 'html' ):
cookedbody =3D apply(HTML(self.text), (self, =
self.REQUEST))
return cookedbody
=20
Document.CookedBody =3D CookedBody
=20
Document.manage_options =3D ( 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=E7ois 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