[Zope3-dev] calling objects when evaluating path expressions

Shane Hathaway shane@zope.com
Fri, 20 Jun 2003 09:59:43 -0400


Steve Alexander wrote:
> However, the following gives an unexpected result.
> 
>   <span tal:replace="foo/bar/spoo" />
> 
> result:
> 
>   <bound method baz of <Foo object at 0x92c668c>>

This result is surprising because it should have thrown an error.  It 
should not have attempted to call foo.bar, and attempting to find "spoo" 
should have raised an AttributeError.

I agree with your proposal and Guido's enhancement--we should rely on 
properties now and not attempt to call anything in path expressions.

I once considered suggesting a minor enhancement to path expressions to 
deal with this: use an exclamation point to call things.  For example::

   <span tal:replace="foo/bar!/spoo" />

As exciting as this makes page templates look <wink>, it could be 
redundant.  The class author could just create a property instead.

Shane