[Zope] Re: Page Template Dynaics

Mikhail mikhail@freehand.ru
Mon, 09 Dec 2002 19:52:28 +0300


Evan Simpson wrote:

> Mikhail wrote:
>> <p metal:use-macro="python:here.getMacro()">
>> 
>> Can you explain this example and show simple script?
>> """
>> return 'path/to/zpt/macros/some'
>> """
>> don't work.
> 
> "getMacro" cannot return a string -- it must return the actual macro
> object.  One way to accomplish this is to use the "restrictedTraverse"
> method on your path string, like so:
> 
> return context.restrictedTraverse('path/to/library.zpt/macros/some')
> 
> Slightly more efficient, if your path is static, would be the following:
> 
> return context.path.to['library.zpt'].macros.some
> 
> On the other hand, you *could* return a path string, if you change your
> use-macro to:
> 
> <p metal:use-macro="python:path(here.getMacro())">
> 
> Cheers,
> 
> Evan @ 4-am

thanks your explanation solve my poblems.


-- 
Mikhail 'Xen' Kashkin (Russia)