[ZCM] [ZC] 2286/ 1 Request "Optimized version of InterfaceBase doesn't use interface's __adapt__"
"Collector: Zope Bugs, Features, and Patches ..." <[email protected]> Tue, 27 Feb 2007 21:56:32 -0500
| Newsgroups | gmane.comp.web.zope.devel.collector-monitor |
|---|---|
| Message-ID | <[email protected]> |
Issue #2286 Update (Request) "Optimized version of InterfaceBase doesn't use interface's __adapt__"
Status Pending, Zope/bug medium
To followup, visit:
http://www.zope.org/Collectors/Zope/2286
==============================================================
= Request - Entry #1 by bromine on Feb 27, 2007 9:56 pm
According to zope.interface documentation, the __call__ of an interface should use __adapt__ in the interface to attempt to adapt the object. This is not so with the optimized C version of InterfaceBase:
from zope.interface import Interface
class Test(Interface):
pass
def adapt(*args, **kwargs):
return 17
from new import instancemethod
Test.__adapt__ = instancemethod(adapt, Test)
print Test.__adapt__(1) # prints 17
Test(1) # Generates an exception
This is not how InterfaceBasePy.__call__ behaves -- it uses interface.__adapt__, which can be customized for each interface. This discrepancy between InterfaceBasePy and the C-optimized InterfaceBase should be eliminated; I believe that the behavior of InterfaceBase should change to match that of InterfaceBasePy.
==============================================================