On Fri, Sep 23, 2005 at 12:06:00PM +0100, Peter Bengtsson wrote:
Please press "Reply-All" and not just to me.
Sorry about that.
That is the correct way of calling PageTemplateFile objects in python code. I've got it working in many places. The error must be either a new zope bug or something else being wrong. Is your setup as simple as you've described in the email?
Yes. This is the class I am using: class TestProd(SimpleItem): """A TestProd object""" meta_type = "TestProd" manage_options = ( {"label": "Edit", "action": "manage_main"}, {"label": "View", "action": "index_html"}) manage_main = PageTemplateFile("templates/mainTestProd", globals()) index_html = PageTemplateFile("templates/indexTestProd", globals()) test = PageTemplateFile("templates/test", globals()) def __init__(self, id, title): self.id = id self.title = title def testit(self, REQUEST=None): return self.test(self, self.REQUEST, something="blah") And the "test" template: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html;charset=ISO-8859-1" /> <meta name="copyright" content="© 2004 & Anders Bruun Olsen <anders(AT)bruun-olsen(DOT)net" /> <link rel="stylesheet" type="text/css" href="css" /> <title tal:content="container/title_or_id">TITLE</title> </head> <body> <div> <p>Welcome to <tal:block tal:replace="container/title_or_id"/></p> <p tal:content="python:str(options)"/> <p tal:content="python:len(request.form.keys())"/> <p tal:content="python:context.absolute_url_path()"/> </div> </body> </html> I have added it to the rootfolder in ZMI with the ID "testing".
What happens when you in that TAL do something like: <br tal:replace="python:str(options)" />
Gives: {'args': ()}
Do the other namespaces work in the page template? Eg. <br tal:replace="python:len(request.form.keys())" /> or <br
Gives: 0
tal:replace="python:context.absolute_url_path()" />
Gives: /testing -- Anders -----BEGIN GEEK CODE BLOCK----- Version: 3.12 GCS/O d--@ s:+ a-- C++ UL+++$ P++ L+++ E- W+ N(+) o K? w O-- M- V PS+ PE@ Y+ PGP+ t 5 X R+ tv+ b++ DI+++ D+ G e- h !r y? ------END GEEK CODE BLOCK------ PGPKey: http://random.sks.keyserver.penguin.de:11371/pks/lookup?op=get&search=0xD4DE...