predicates.py
changeset 9256 697a8181ba30
parent 9157 3e4bef7d514d
child 9344 4da3ef764395
--- a/predicates.py	Mon Aug 26 16:12:30 2013 +0200
+++ b/predicates.py	Mon Aug 26 16:14:09 2013 +0200
@@ -204,27 +204,6 @@
 # remember, these imports are there for bw compat only
 __BACKWARD_COMPAT_IMPORTS = (yes,)
 
-def score_interface(etypesreg, eclass, iface):
-    """Return XXX if the give object (maybe an instance or class) implements
-    the interface.
-    """
-    if getattr(iface, '__registry__', None) == 'etypes':
-        # adjust score if the interface is an entity class
-        parents, any = etypesreg.parent_classes(eclass.__regid__)
-        if iface is eclass:
-            return len(parents) + 4
-        if iface is any: # Any
-            return 1
-        for index, basecls in enumerate(reversed(parents)):
-            if iface is basecls:
-                return index + 3
-        return 0
-    # XXX iface in implements deprecated in 3.9
-    if implements_iface(eclass, iface):
-        # implementing an interface takes precedence other special Any interface
-        return 2
-    return 0
-
 
 # abstract predicates / mixin helpers ###########################################
 
@@ -745,53 +724,6 @@
         return 1 # necessarily true if we're there
 
 
-class implements(EClassPredicate):
-    """Return non-zero score for entity that are of the given type(s) or
-    implements at least one of the given interface(s). If multiple arguments are
-    given, matching one of them is enough.
-
-    Entity types should be given as string, the corresponding class will be
-    fetched from the entity types registry at selection time.
-
-    See :class:`~cubicweb.predicates.EClassPredicate` documentation for entity
-    class lookup / score rules according to the input context.
-
-    .. note::
-
-       when interface is an entity class, the score will reflect class
-       proximity so the most specific object will be selected.
-
-    .. note::
-
-       deprecated in cubicweb >= 3.9, use either
-       :class:`~cubicweb.predicates.is_instance` or
-       :class:`~cubicweb.predicates.adaptable`.
-    """
-
-    def __init__(self, *expected_ifaces, **kwargs):
-        emit_warn = kwargs.pop('warn', True)
-        super(implements, self).__init__(**kwargs)
-        self.expected_ifaces = expected_ifaces
-        if emit_warn:
-            warn('[3.9] implements predicate is deprecated, use either '
-                 'is_instance or adaptable', DeprecationWarning, stacklevel=2)
-
-    def __str__(self):
-        return '%s(%s)' % (self.__class__.__name__,
-                           ','.join(str(s) for s in self.expected_ifaces))
-
-    def score_class(self, eclass, req):
-        score = 0
-        etypesreg = req.vreg['etypes']
-        for iface in self.expected_ifaces:
-            if isinstance(iface, basestring):
-                # entity type
-                try:
-                    iface = etypesreg.etype_class(iface)
-                except KeyError:
-                    continue # entity type not in the schema
-            score += score_interface(etypesreg, eclass, iface)
-        return score
 
 def _reset_is_instance_cache(vreg):
     vreg._is_instance_predicate_cache = {}