[Zope] dynamically generated TAL not being interpreted
N. Thomas
nthomas@cise.ufl.edu
Tue, 4 Mar 2003 23:18:34 -0500
* Dieter Maurer <dieter@handshake.de> [2003-03-03 20:56:46 +0100]:
> N. Thomas wrote at 2003-3-1 23:46 -0500:
> > We have a script that generates TAL. The problem is that the content
> > is not being interpeted as TAL by Zope, but rather as raw HTML.
>
> You must make a Page Template object from your TAL source code, wrap
> it in an appropriate context (--> "__of__") and return it (or call it
> to let it render).
>
> You can do this only in an External Method (or other filesystem based
> code).
Well, this was a start in the right direction. But after wading through
the archives, the nearest solution I can cruft together is an external
method like this:
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
def talgen():
zptstr = \
"""
<html>
<body>
If properlu rendered,
this sentence <b tal:omit-tag="">should contain no tags.</b>
</body>
</html>
"""
zptid = 'foobar'
z = ZopePageTemplate(id=zptid, text=zptstr, content_type="text/html")
return z
But this returns an error, probably because I'm stabbing in the dark.
Also, I have no idea where exactly to stick the "__of__" method. (I did
look at the relevant sections in
http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html though.)
My questions:
Where is the API for Products.PageTemplates.ZopePageTemplate
documented?
In Products.PageTemplates, should I use PageTemplate, or
PageTemplateFile, or ZopePageTemplate?
In the code above, I see that ZopePageTemplate requires that an id
be passed in, does that mean that I have to create a temporary ZPT
object in the Zope filesystem, return that, and somehow make sure it
is destroyed afterwards? I only passed in 'foobar' because it was
required.
Also, if anyone could point me to a fragment of code that does something
similar it would be much appreciated.
thomas
--
N. Thomas
nthomas@cise.ufl.edu
Etiamsi occiderit me, in ipso sperabo