[Checkins] SVN: zope.interface/branches/regebro-python3/src/zope/interface/declarations.py The Odd class that doesn't subclass from type causes some problems. I revert the test, and now assume
Lennart Regebro
regebro at gmail.com
Tue Apr 7 05:45:28 EDT 2009
Log message for revision 98971:
The Odd class that doesn't subclass from type causes some problems. I revert the test, and now assume
it's a class unless it's a method or function. 95 out of 152 tests run now.
Changed:
U zope.interface/branches/regebro-python3/src/zope/interface/declarations.py
-=-
Modified: zope.interface/branches/regebro-python3/src/zope/interface/declarations.py
===================================================================
--- zope.interface/branches/regebro-python3/src/zope/interface/declarations.py 2009-04-07 09:25:50 UTC (rev 98970)
+++ zope.interface/branches/regebro-python3/src/zope/interface/declarations.py 2009-04-07 09:45:28 UTC (rev 98971)
@@ -33,7 +33,7 @@
from zope.interface.interface import InterfaceClass, Specification
from ro import mergeOrderings, ro
import exceptions
-from types import ModuleType
+from types import ModuleType, MethodType, FunctionType
from zope.interface.advice import addClassAdvisor
# Registry of class-implementation specifications
@@ -491,16 +491,17 @@
self.interfaces = interfaces
def __call__(self, ob):
- if isinstance(ob, DescriptorAwareMetaClasses):
- # XXX Here I am!
+ if isinstance(ob, (FunctionType, MethodType)):
+ spec = Implements(*self.interfaces)
+ try:
+ ob.__implemented__ = spec
+ except AttributeError:
+ raise TypeError("Can't declare implements", ob)
+ return ob
+ else:
+ # Assume it's a class:
classImplements(ob, *self.interfaces)
- return ob
- spec = Implements(*self.interfaces)
- try:
- ob.__implemented__ = spec
- except AttributeError:
- raise TypeError("Can't declare implements", ob)
- return ob
+ return ob
def _implements(name, interfaces, classImplements):
frame = sys._getframe(2)
More information about the Checkins
mailing list