Calling a ZPT macro, with parameters, from a python script
Is there a way to call a specific macro in a ZPT from a python script? So far, the only way I've found to do this is by calling the macro template from another template, then calling the wrapper, like: wrapper: <metal:wrapper use-macro="python:path('here/my_macros/macros/'+options['macro'])" /> script: context.my_wrapper(macro='my_macro',foo='whatever') Is there a way to do this without wrapping the macro template in another template call? -- View this message in context: http://www.nabble.com/Calling-a-ZPT-macro%2C-with-parameters%2C-from-a-pytho... Sent from the Zope - General mailing list archive at Nabble.com.
Sean F wrote at 2007-8-29 11:58 -0700:
Is there a way to call a specific macro in a ZPT from a python script?
So far, the only way I've found to do this is by calling the macro template from another template, then calling the wrapper, like:
wrapper: <metal:wrapper use-macro="python:path('here/my_macros/macros/'+options['macro'])" />
script: context.my_wrapper(macro='my_macro',foo='whatever')
Is there a way to do this without wrapping the macro template in another template call?
I doubt that you can do this in untrusted code. To call a macro, the caller must provide some context (note that a macro is usually used inside a template and this template provides a namespace for variables and ways to handle slots assignments). I would be very surprised if you could build the context objects in untrusted code. -- Dieter
participants (2)
-
Dieter Maurer -
Sean F