RE: [Zope] calling python from template
Hi, Try using : <p tal:content="python:here.listObjects('departments', 'priority')">content of listObjects </p> I'm not sure why the 'here.' part must be specified. Anyone ?? Greetz, Daniel
-----Original Message----- From: David Bear [mailto:David.Bear@asu.edu] Sent: woensdag 20 november 2002 1:51 To: zope@zope.org Subject: [Zope] calling python from template
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?
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Wed, Nov 20, 2002 at 10:22:34AM +0100, Dani?l Hooymans wrote:
Hi,
Try using : <p tal:content="python:here.listObjects('departments', 'priority')">content of listObjects </p>
I'm not sure why the 'here.' part must be specified. Anyone ??
well, listObjects is not a function floating around nowhere. It's a method of ObjectManager instances. "here" refers to the current context, with acquisition. Think of it like "the place where I happen to be when this code gets called." YOu may be used to DTML where this kind of thing is glossed over. You have to be a bit more specific in TAL. Other useful bindings: request (the current request), container (the container where this page template actually lives)... there's a similar concept to "here" in Script (Python), but it's called "context" instead of "here", just to be needlessly inconsistent. (I think historically, Script and Page Template were developed independently at roughly the same time.) Thankfully, it's been decreed that this concept will be called "context" universally in Zope 3. --PW -- Paul Winkler http://www.slinkp.com "Welcome to Muppet Labs, where the future is made - today!"
participants (2)
-
Daniël Hooymans -
Paul Winkler