[Zope] Re: metal Macros from PageTemplateFiles?

Robert Casties casties at mpiwg-berlin.mpg.de
Wed Jan 19 16:10:05 EST 2005


Dieter Maurer wrote:
>>    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)"

That was not the main problem (as I had tried that before) but I tried 
to use the method in a traversal 
"metal:use-macro="here/content_template/macros/page" which didn't work. 
(Could that be made to work?)

>  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)

Interesting, but I don't really understand the details.

Can I have an attribute and a method of the same name?

What does ComputedAttribute do? I found some documentation hints on the 
web but what's the second parameter? Can I pass parameters to the function?

Regards
	Robert



More information about the Zope mailing list