[ZPT] calling ZPT from Python Script
Dieter Maurer
dieter@handshake.de
Mon, 10 Jun 2002 20:47:53 +0200
Olivier Laurent writes:
> ...
> I have a 'template_standard' ZPT which defines a 'page' macro. In this
> macro I call a 'get_content' Python Script which handles the content. Here
> is the script call from the ZPT:
> <div tal:replace="structure python:here.get_content(here, request,
> options)"></div>
>
> And here is the Python Script (simplified):
> ## Parameters: client, mapping, **kargs
> return context.content_html(client, mapping, kargs)
That looks wrong:
"**kwarg" catches only keyword but no positional argument.
You call "get_content" with the positional argument "options"
but have the formal parameter "**kwargs" at this position.
This should give you a "TypeError".
You can use Python's build in function "apply" to turn a dictionary
into a sequence of keyword arguments.
You probably want this, too, when you call "content_html".
Looks like:
apply(content.content_html,(client,mapping),kwargs)
Dieter