On Jan 7, 2008, at 2:35 PM, Dieter Maurer wrote:
Dieter Maurer wrote at 2008-1-7 17:55 +0100:
Yesterday, I released "dm.zdoc" and today I find problems.
The analysis revealed:
The class "webdav.EtagSupport.EtagSupport" has initially no attributes "__provides__" and "__providedBy__".
For still unknown reasons, it suddenly gets these attributes. "__provides__" is a "zope.interface.declarations.ClassProvides". Therefore, I expect that Zope 3 or "five" is responsible for these additions.
"EtagSupport" is in the mro of "ManagableIndex". But nevertheless, "ManagableIndex.__provides__" results in an "AttributeError".
Here is a transscript reproducing the problem:
import App.FindHomes from webdav.EtagSupport import EtagSupport EtagSupport.__provides__ Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: class EtagSupport has no attribute '__provides__' from Products.ManagableIndex.ManagableIndex import ManagableIndex /usr/local/lib/python24.zip/whrandom.py:38: DeprecationWarning: the whrandom module is deprecated; please use the random module DeprecationWarning) EtagSupport.__provides__ <zope.interface.declarations.ClassProvides object at 0x40b5566c> ManagableIndex.__provides__ Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: __provides__ from inspect import getmro EtagSupport in getmro(ManagableIndex) True
Any ideas?
I think I understand the behavior -- and I think it is a "zope.interface" bug.
No, it is intended behavior.
Under some circumstances "zope.interface" adds a "__provides__" descriptor to a class. The descriptor is implemented in "zope/interface/_zope_interface_coptimizations.c" and called "CPB_descr_get".
While "__implements__" is inherited by derived classes, the inherited "__provides__" refuses to work for a derived class and raises "AttributeError: __provides__" instead, the AttriuteError, I observe....
That is intentional.
I will try to make my failure independent of "ManagableIndex" and then file a bug report.
I'm unclear why this caused a problem for you. You never said, afaict, what actually broke for you. What expectation did you have that is unsatisfied? My main gripe with the way this works is that classes get mutated. If I ever redo this someday, I'd use a data structure external to the classes. Modifying the classes was a mistake. Jim -- Jim Fulton Zope Corporation