[Zope3-dev] re: calling objects when evaluating path expressions
Steve Alexander
steve@cat-box.net
Fri, 20 Jun 2003 18:37:42 +0300
>> Conclusion 2: TALES should not try to call things at all. This should be
>> left up to the Zope traversal components, so that the behaviour may be
>> customised.
>
> Now that we have properties, I see no reason to ever call things at
> all. The call-if-callable behavior is a carryover from Zope2 and
> pre-new-style-classes Python, when it was really painful to provide a
> computed attribute.
I agree for TALES.
>> 3: Making the zope 3 default traversal machinery call an object on
>> traversal if and only if the following conditions hold:
>>
>> a: the object provides no interfaces
>>
>> b: the object has a __call__ attribute
>>
>> c: on inspection, it appears that the __call__ attribute can be
>> called with no arguments
>>
>> This will most usefully apply to instance methods, static methods,
>> class methods and method-wrappers (which are how builtin methods
>> appear to Python).
>
> I'd propose to skip even this. Or is that too radical?
I think that's too radical. Such a spartan (or is that explicit)
approach would be fine if objects presented using page templates in Zope
3 were always written afresh for Zope 3. However, one of the goals of
Zope 3 is to allow pre-existing code, and code written for other
purposes, to be presented from Zope 3.
So, I think Zope should provide facilities over and above TALES to call
things that obviously should be called.
Users of page templates aren't necessarily python programmers. And, when
we have a DTML that uses path expressions, users of DTML won't
necessarily be python programmers. I think many of these users will
appreciate a small amount of well-contained implicitness in exchange for
making path expressions more concise.
--
Steve Alexander