Robert Casties wrote at 2005-1-19 14:29 +0100:
Is it possible (and how?) to use a procedure in a product to produce a PageTemplate that defines a macro, that can be used in another PageTemplate?
I tried:
class SomeClass(Folder):
content_template = PageTemplateFile("/some/file/template.zpt")
and the direct ssignment to a variable works, but it is not exactly what I need (I need to check with the actual instance).
But when I try to do:
def content_template(self): pt = PageTemplateFile("/some/file/template.zpt") return pt
then the procedure is never called and I get an error in the ZPT that tries to use the macro:
Error Type: AttributeError Error Value: content_templatemacros
Two errors: 1. as Tino already pointed out: you forgot the ".__of__(self)" 2. you must call your "content_template" method (contrary to your "content_template" attribute). The easiest way would be a "ComputedAttribute", something like from ComputedAttribute import ComputedAttribute ... def content_template(self): ... content_template = ComputedAttribute(content_template, 1)
Somewhere I read a vage reference to invoke "cook" but I don't know how.
PageTemplates get automatically "cook"ed, when necessary. -- Dieter