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

Steve Alexander steve@z3u.com
Tue, 05 Aug 2003 13:50:15 +0300


>> Ok, I'll save you looking at the code:
>>
>>     if getattr(r, '__class__', 0) == MethodType:
>>         return r()
> 
> 
> Oooo... is that a Python 2.3 ism?
> 
> Shouldn't it be:
> 
> if isintance(r,MethodType):
>    return r()

Getting the __class__ attribute works as expected in the presence of 
proxies. isinstance will work properly in the presence of proxies only 
in Python 2.3. This code can be simplified when Python 2.3 is required 
for Zope 3.


> But, for the default traverser, it applies to all segments, not just the 
> last one? If so, cool :-)

Yes.


>> Why would you want to do something different than the traversable 
>> adapter for the objects you are traversing?
> 
> 
> Well, do all object implement traversable adapters? I would haev thought 
> most would just use the default traverser? In that case, wouldn't you 
> need to implemetn a traverser if you wanted traversal from that object 
> to the next name in the path to not have the result of traversing that 
> name being called?

The default traverser only calls MethodType things. It doesn't call 
anything else.

The default traverser meets the needs you describe in your question. 
Perhaps you meant to ask a different question.


--
Steve Alexander