Rendering PageTemplateFile
...(the last mail was in the wrong thread)... Salut, is there any way to render a page template file that is located on the hard disk? Code excerpt in a product: def foo(self): pt = PageTemplateFile('show.zpt', _prefix=skins_prefix) print pt # prints <PageTemplateFile at 0x89c5000> return pt() # --> error There is nothing wrong with the page template (actually it doesn't contain any tals just plain text). (The idea behind this is that I want to decide which template to show. So the skins_prefix may change.) But rendering will fail. Thanks a lot, Jens. Appendix Error Type: AttributeError Error Value: other ... Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 39, in call_object Module Products.cms2.products.documentpool.DocumentPoolIndex, line 73, in show Module Shared.DC.Scripts.Bindings, line 252, in __call__ Module Shared.DC.Scripts.Bindings, line 281, in _bindAndExec Module Shared.DC.Scripts.Bindings, line 1, in ? Module Shared.DC.Scripts.Bindings, line 232, in _getTraverseSubpath
Jens Dobberthin wrote:
...(the last mail was in the wrong thread)...
Salut,
is there any way to render a page template file that is located on the hard disk?
Code excerpt in a product:
def foo(self): pt = PageTemplateFile('show.zpt', _prefix=skins_prefix) print pt # prints <PageTemplateFile at 0x89c5000> return pt() # --> error
There is nothing wrong with the page template (actually it doesn't contain any tals just plain text). (The idea behind this is that I want to decide which template to show. So the skins_prefix may change.)
You need to give it some context. def foo(self): pt = PageTemplateFile('show.zpt', _prefix=skins_prefix) return pt(self, self.REQUEST) Alternatively you could also use PageTemplate() def foo(self): pt = PageTemplate() pt.write('some zpt code, perhaps from a file.') return pt(self, self.REQUEST) Botha approached make you compile the zpt code every time, which is expensive. It's better to store these templates in the zodb. It is possible to dynamically select the template via a Python Script in zpt. Your approach seems wrong! regards Max M
participants (2)
-
Jens Dobberthin -
Max M