[Zope3-dev] calling objects when evaluating path expressions

Steve Alexander steve@cat-box.net
Fri, 20 Jun 2003 18:29:19 +0300


>> I can't find Guido's enhancement just now. Perhaps he posted it via 
>> his time-machine.
> 
> Rather than "enhancement", I should have just called it a "follow-up".
> 
> http://mail.zope.org/pipermail/zope3-dev/2003-June/007373.html

Thanks. For some reason, my zope3-dev subscription hasn't received that 
message.


> Here's another approach that doesn't add any syntax.  Recently, we added 
> the ability to use prefixes in the middle of path expressions, so 
> perhaps we could define the "call:" prefix to mean "call the method 
> named X, passing no arguments".
> 
> <span tal:replace="foo/call:bar/baz" />

That's very similar to the syntax I jokingly suggested when talking 
about this with Jim on irc earlier today:

   <span tal:replace="foo/bar/zope:call/baz" />

I like your version better though. So, 'call' would essentially be a 
proxy that makes no-args methods into gettable properties.


> On a related note, a few other prefixes could disambiguate traversal. 
> Consider the problem of fetching an item called "keys" from a dictionary 
> using a path expression.  Unless Zope 3 has changed the policy, basic 
> traversal tries attributes first and items second, so path expressions 
> can't easily access items with certain names.

Actually, Zope 3 has changed the policy. For speed, and because we use a 
lot of dicts, dicts are always traversed using __getitem__.

> An "item:" prefix could solve this.

It would. This would be useful for containers.

--
Steve Alexander