Brian, This is an excellent bug analysis. I suggest that we create a new PyCallable_Check function that works in the presence of wrappers, perhaps called PyCallable_CheckW(). If it is placed in Acquisition.c then cDocumentTemplate.c will have to #include "Acquisition.h". Then we need to replace PyCallable_Check in probably more than just cDocumentTemplate. Shane Dieter Maurer wrote:
Recently, several posters have reported strange "AttributeError __call__" exceptions.
The most precise was a report by Oleg Broytmann:
/index_html DTML Document <dtml-var standard_html_header> /standard_html_header DTML Method <dtml-with sub></dtml-with> /sub Folder
When he calls "/sub/index_html", he gets this "AttributeError __call__" for "sub".
He observed the problem on Zope 2.1.4 and 2.2a4.
I partially analysed this problem report under Zope 2.1.6:
In "MM_cget", "sub" is retrieved as an "ImplicitAcquirerWrapper" (correct).
In line 373, however, "PyCallable_Check(sub)" returned "1", which is probably wrong, because a folder is not callable. The "ImplicitAcquirerWrapper"'s "tp_call" mislead "PyCallable_Check".
In line 376, the attribute "py_isDocTemp" is looked up and succeeds. Therefore, the folder "sub" is seen as a Document Template, which definitely is not true. The following call fails because it arrives at CallMethodO in "Acquisition.c:119" which looks for a non-excisting "__call__" method.
Dieter