[Zope3-dev] zope3-dev proposal on changing implicitly calling

Steve Alexander steve@z3u.com
Sat, 02 Aug 2003 20:41:12 +0300


Chris Withers wrote:
> Steve Alexander wrote:
> 
>>> How do you configure it?
>>
>>
>> You provide an adapter for ITraversable.
>> zope/app/interfaces/traversing.py
> 
> 
> What would a simple example of doing that look like?

Look in the "friendlyfolder" add-on product.

http://cvs.zope.org/Products3/friendlyfolder/


>> There's a special case in the code, marked with an XXX that I inserted 
>> at about the time I made the proposal about making TALES not 
>> implicitly call objects that have a __call__ attribute. This special 
>> case detects if an attribute that has been traversed is a method. If 
>> it is a method, then the method is called with no arguments.
> 
> 
> Hmmm, so the default traverser:
> 
> 1. looks up by attributes
> 2. looks up by item access

Yes.


> 3. tries to call the end result (or the result of travesing each name?) 
> with no arguments

No. The base TALES code tries to call the end result, with no arguments, 
if it has a __call__ attribute. This is what I propose to change, to 
allow the Zope traversal machinery to control this.

The special case in the default traverser is that if an attribute that 
has been traversed is a method, it is called with no arguments.


> What happens if one of the things that gets called takes more than no 
> arguments?

You'll get a TypeError.

This is the standard Python error for this case. This is the same error 
you get if you try to use map() with a function that requires no 
arguments or requires two or more arguments.

--
Steve Alexander