[ZPT] calling ZPT from Python Script

Olivier Laurent oli@aragne.com
Mon, 10 Jun 2002 13:30:37 +0200


I try to use Formulator with ZPT. I have a form which calls a
'do_validate' Python Script.

If there are Formulator errors, the script returns something like this:
return container.my_folder.index_html(error_fields=error_fields)

The problem is that the way I'm using ZPT is probably a little bit weird:

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)

I have one 'index_html' ZPT on the top of the site with:
<div metal:use-macro="container/template_standard/macros/page"></div>

The advantage of this is that whenever I want to add a new page, I don't
have to add a line to call a macro and I don't have to add a line to fill
the slot. I just add a Folder with a 'content_html' ZPT (or DTML Method)
in it. And I can directly enter the content. I save 4 lines: 2 <div> and 2
</div>.

Here is the problem: I don't retrieve the options dictionnary when the
'do_validate' Python Script returns this:
return container.my_folder.index_html(error_fields=error_fields)

But I do if I change the Python script to:
return container.my_folder.content_html(error_fields=error_fields)

PS: What would have been easier is doing this:
    return container.my_folder(error_fields=error_fields)

    But it says that Folders are not callable.

I hope my explanations were not too cryptic.

-- 
Olivier Laurent.
P3B    : Club Python(-Zope) Belge --------- http://www.p3b.org
OS3B   : Club Open-Software(-Linux) Carolo  http://www.os3b.org 
Aragne : Python-Zope Solutions & Formations http://www.aragne.com