[Zope] calling python from template

Dieter Maurer dieter@handshake.de
Wed, 20 Nov 2002 19:55:57 +0100


David Bear writes:
 > I want to call a python script from a page template but I don't know how to 'name' the script, ie I don't know how acquisition will find it.  
 > 
 > my script lives if /folderA/folderB
 > by page templated list is /folderA/folderB/folderC
 > 
 > I use <p tal:content="python:listObjects('departments', 'priority')">content of listObjects </p>
 > 
 > to call the listObjects script in folderB -- but zope isn't finding it.
 > 
 > what simple thing am I missing?
You forgot to read the TALES documentation ;-)

  There is only a small set of built in variables that can be accessed
  directly in ZPT-TALES, e.g. "here", "container", "template", "user", ...

  All other objects must be accessed indirectly via expressions
  starting in these built in variables.

You should be able to access "listObjects" by "container.listObjects".
"here.listObjects" would probably work, too.


Dieter