[Zope] calling python from template

Paul Winkler pw_lists@slinkp.com
Wed, 20 Nov 2002 09:33:54 -0800


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!"