[Zope3-checkins] CVS: Zope3/src/zope/interface -
_zope_interface_coptimizations.c:1.4 adapter.py:1.8
implementor.py:1.8 interface.py:1.21 interfaces.py:1.21
surrogate.py:1.7 type.py:1.12 verify.py:1.8
Jim Fulton
jim at zope.com
Fri Mar 5 17:10:01 EST 2004
Update of /cvs-repository/Zope3/src/zope/interface
In directory cvs.zope.org:/tmp/cvs-serv15449/src/zope/interface
Modified Files:
_zope_interface_coptimizations.c adapter.py implementor.py
interface.py interfaces.py surrogate.py type.py verify.py
Log Message:
Renamed interface methods:
isImplementedByInstancesOf to implementedBy
isImplementedBy to providedBy
=== Zope3/src/zope/interface/_zope_interface_coptimizations.c 1.3 => 1.4 ===
--- Zope3/src/zope/interface/_zope_interface_coptimizations.c:1.3 Wed Jan 21 16:58:47 2004
+++ Zope3/src/zope/interface/_zope_interface_coptimizations.c Fri Mar 5 17:09:28 2004
@@ -275,12 +275,12 @@
"Test whether a specification is or extends another"
;
-static char Spec_isImplementedBy__doc__[] =
+static char Spec_providedBy__doc__[] =
"Test whether an interface is implemented by the specification"
;
static PyObject *
-Spec_isImplementedBy(PyObject *self, PyObject *ob)
+Spec_providedBy(PyObject *self, PyObject *ob)
{
PyObject *decl, *item;
@@ -299,12 +299,12 @@
}
-static char Spec_isImplementedByInstancesOf__doc__[] =
+static char Spec_implementedBy__doc__[] =
"Test whether the specification is implemented by instances of a class"
;
static PyObject *
-Spec_isImplementedByInstancesOf(PyObject *self, PyObject *cls)
+Spec_implementedBy(PyObject *self, PyObject *cls)
{
PyObject *decl, *item;
@@ -320,12 +320,12 @@
}
static struct PyMethodDef Spec_methods[] = {
- {"isImplementedBy",
- (PyCFunction)Spec_isImplementedBy, METH_O,
- Spec_isImplementedBy__doc__},
- {"isImplementedByInstancesOf",
- (PyCFunction)Spec_isImplementedByInstancesOf, METH_O,
- Spec_isImplementedByInstancesOf__doc__},
+ {"providedBy",
+ (PyCFunction)Spec_providedBy, METH_O,
+ Spec_providedBy__doc__},
+ {"implementedBy",
+ (PyCFunction)Spec_implementedBy, METH_O,
+ Spec_implementedBy__doc__},
{"isOrExtends", (PyCFunction)Spec_extends, METH_O,
Spec_extends__doc__},
=== Zope3/src/zope/interface/adapter.py 1.7 => 1.8 ===
--- Zope3/src/zope/interface/adapter.py:1.7 Fri Nov 21 12:11:43 2003
+++ Zope3/src/zope/interface/adapter.py Fri Mar 5 17:09:28 2004
@@ -69,10 +69,10 @@
def register(self, require, provide, object):
- if require is not None and not IInterface.isImplementedBy(require):
+ if require is not None and not IInterface.providedBy(require):
raise TypeError(
"The require argument must be an interface (or None)")
- if not IInterface.isImplementedBy(provide):
+ if not IInterface.providedBy(provide):
raise TypeError(
"The provide argument must be an interface")
@@ -159,12 +159,12 @@
required_interfaces = required
provided_interfaces = provided
- if IInterface.isImplementedBy(required_interfaces):
+ if IInterface.providedBy(required_interfaces):
required_interfaces = (required_interfaces, )
if provided_interfaces:
- if IInterface.isImplementedBy(provided_interfaces):
+ if IInterface.providedBy(provided_interfaces):
provided_interfaces = (provided_interfaces, )
r = {}
=== Zope3/src/zope/interface/implementor.py 1.7 => 1.8 ===
--- Zope3/src/zope/interface/implementor.py:1.7 Fri Nov 21 12:11:43 2003
+++ Zope3/src/zope/interface/implementor.py Fri Mar 5 17:09:28 2004
@@ -66,7 +66,7 @@
def register(self, provide, object):
- if not IInterface.isImplementedBy(provide):
+ if not IInterface.providedBy(provide):
raise TypeError(
"The provide argument must be an interface (or None)")
=== Zope3/src/zope/interface/interface.py 1.20 => 1.21 ===
--- Zope3/src/zope/interface/interface.py:1.20 Tue Mar 2 09:26:59 2004
+++ Zope3/src/zope/interface/interface.py Fri Mar 5 17:09:28 2004
@@ -16,6 +16,7 @@
$Id$
"""
import sys
+import warnings
import weakref
from types import FunctionType
from ro import ro
@@ -79,7 +80,7 @@
class SpecificationBasePy(object):
- def isImplementedBy(self, ob):
+ def providedBy(self, ob):
"""Is the interface implemented by an object
>>> from zope.interface import *
@@ -91,24 +92,24 @@
>>> class X:
... pass
>>> x = X()
- >>> I1.isImplementedBy(x)
+ >>> I1.providedBy(x)
False
- >>> I1.isImplementedBy(C)
+ >>> I1.providedBy(C)
False
- >>> I1.isImplementedBy(c)
+ >>> I1.providedBy(c)
True
>>> directlyProvides(x, I1)
- >>> I1.isImplementedBy(x)
+ >>> I1.providedBy(x)
True
>>> directlyProvides(C, I1)
- >>> I1.isImplementedBy(C)
+ >>> I1.providedBy(C)
True
"""
spec = providedBy(ob)
return self in spec._implied
- def isImplementedByInstancesOf(self, cls):
+ def implementedBy(self, cls):
"""Do instances of the given class implement the interface?"""
spec = implementedBy(cls)
return self in spec._implied
@@ -196,7 +197,25 @@
# Copy some base class methods for speed
isOrExtends = SpecificationBase.isOrExtends
- isImplementedBy = SpecificationBase.isImplementedBy
+ providedBy = SpecificationBase.providedBy
+
+ #########################################################################
+ # XXX Backward Compat
+ def isImplementedByInstancesOf(self, cls):
+ warnings.warn(
+ "isImplementedByInstancesOf has been renamed to implementedBy",
+ DeprecationWarning, stacklevel=1,
+ )
+ return self.implementedBy(cls)
+
+ def isImplementedBy(self, ob):
+ warnings.warn(
+ "isImplementedBy has been renamed to providedBy",
+ DeprecationWarning, stacklevel=2,
+ )
+ return self.providedBy(ob)
+ #
+ #########################################################################
def __init__(self, bases=()):
self._implied = {}
=== Zope3/src/zope/interface/interfaces.py 1.20 => 1.21 ===
--- Zope3/src/zope/interface/interfaces.py:1.20 Tue Jan 20 16:17:41 2004
+++ Zope3/src/zope/interface/interfaces.py Fri Mar 5 17:09:28 2004
@@ -193,7 +193,7 @@
"""
- def isImplementedBy(object):
+ def providedBy(object):
"""Test whether the interface is implemented by the object
Return true of the object asserts that it implements the
@@ -201,7 +201,7 @@
interface.
"""
- def isImplementedByInstancesOf(class_):
+ def implementedBy(class_):
"""Test whether the interface is implemented by instances of the class
Return true of the class asserts that its instances implement the
=== Zope3/src/zope/interface/surrogate.py 1.6 => 1.7 ===
--- Zope3/src/zope/interface/surrogate.py:1.6 Tue Mar 2 17:56:54 2004
+++ Zope3/src/zope/interface/surrogate.py Fri Mar 5 17:09:29 2004
@@ -678,7 +678,7 @@
matched_factories = None
for interfaces, factories in adapters.iteritems():
for iface, ob in zip(interfaces, obs):
- if not iface.isImplementedBy(ob):
+ if not iface.providedBy(ob):
break # This one is no good
else:
if _subscription:
=== Zope3/src/zope/interface/type.py 1.11 => 1.12 ===
--- Zope3/src/zope/interface/type.py:1.11 Fri Nov 21 12:11:43 2003
+++ Zope3/src/zope/interface/type.py Fri Mar 5 17:09:29 2004
@@ -47,7 +47,7 @@
self._reg = data
def register(self, interface, object):
- if not (interface is None or IInterface.isImplementedBy(interface)):
+ if not (interface is None or IInterface.providedBy(interface)):
if isinstance(interface, (type, types.ClassType)):
interface = zope.interface.implementedBy(interface)
else:
@@ -57,7 +57,7 @@
self._reg[interface] = object
def unregister(self, interface):
- if interface is None or IInterface.isImplementedBy(interface):
+ if interface is None or IInterface.providedBy(interface):
if interface in self._reg:
del self._reg[interface]
else:
=== Zope3/src/zope/interface/verify.py 1.7 => 1.8 ===
--- Zope3/src/zope/interface/verify.py:1.7 Sat Dec 6 07:29:58 2003
+++ Zope3/src/zope/interface/verify.py Fri Mar 5 17:09:29 2004
@@ -40,9 +40,9 @@
"""
if vtype == 'c':
- tester = iface.isImplementedByInstancesOf
+ tester = iface.implementedBy
else:
- tester = iface.isImplementedBy
+ tester = iface.providedBy
if not tentative and not tester(candidate):
raise DoesNotImplement(iface)
More information about the Zope3-Checkins
mailing list