[ZPT] Re: Accessing ZPT options name in Python Script

Evan Simpson evan at 4-am.com
Mon Apr 19 15:14:24 EDT 2004


Fernando Martins wrote:
> It's just a pitty the difference in semantics (in the path vs python syntax)
> from what should be the same thing, no?
> 
> Care to explain what's going on?

When you use <dtml-var foo>, you are invoking a fair amount of DTML 
"magic" in order to find 'foo' and figure out how to call it.  If 'foo' 
turns out to be a DTML Method or Document, dtml-var knows to pass the 
REQUEST object and the namespace stack to it.  If you have ever been 
forced to use a python expression to call DTML from DTML, you know how 
painful the loss of this "magic" can be -- you end up having to write 
something like <dtml-var expr="foo(REQUEST, _,and_so_forth=1)">.

ZPT has a similar dichotomy.  Path evaluation includes a bit of "magic" 
(although not so much as DTML) to make life easier, and this includes 
recognizing when a called object wants namespace information.  There's a 
(probably undocumented) __render_with_namespace__ interface implemented 
by Shared/DC/Scripts/Bindings.py, that allows an object to be called 
DTML-style.  DTML objects don't use this, marking themselves with an 
'isDocTemp' attribute instead :-P

Python expressions, in both worlds, mean exactly what they say.  There's 
very little room for "magic", and certainly no place for trying to 
re-interpret function calls, so you end up having to pass everything 
explicitly.

Cheers,

Evan @ 4-am





More information about the ZPT mailing list