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

Steve Alexander steve@z3u.com
Mon, 04 Aug 2003 14:19:28 +0300


>> 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.
>
 > How does the default traverse decide is something is a method?

UTSL :-)

Ok, I'll save you looking at the code:

     if getattr(r, '__class__', 0) == MethodType:
         return r()


> So, just checking, this calling behaviour applies to all segments within 
> a path to be traversed?

The use of an ITraversable adapter applies to all segments within a path 
to be traversed.

Like I said, at this point, the calling behaviour applies only to the 
default traversable adapter, and only to methods.


> Hmmm, if you have a path and you don't want the segments to be called, 
> you have to write a special traverse, right?

Why would you want to do something different than the traversable 
adapter for the objects you are traversing?


>>> What happens if one of the things that gets called takes more than no 
>>> arguments?
>>
>>
>> You'll get a TypeError.
> 
> 
> ...so you'd have to write a specia ltraverse in this case?

If you have special traversal requirements for particular objects, you 
can write a special traversable adapter that knows how to traverse those 
objects.

--
Steve Alexander