[selectors] for bacwkard compatibility, we must search the mro, not just the current class, in order not to miss __selectors__ in classes that do not redefine it tls-sprint
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Tue, 24 Feb 2009 16:12:19 +0100
branchtls-sprint
changeset 943 9fdfa8d38359
parent 941 7574822b0d03
child 944 e9da555f19c5
[selectors] for bacwkard compatibility, we must search the mro, not just the current class, in order not to miss __selectors__ in classes that do not redefine it
vregistry.py
--- a/vregistry.py	Tue Feb 24 12:00:01 2009 +0100
+++ b/vregistry.py	Tue Feb 24 16:12:19 2009 +0100
@@ -126,22 +126,25 @@
     # XXX bw compat code
     @classmethod
     def build___select__(cls):
-        classdict = cls.__dict__
-        if ('__select__' in classdict and '__selectors__' in classdict
-            and not '__selgenerated__' in classdict):
-            raise TypeError("__select__ and __selectors__ can't be used together on class %s" % cls)
-        if '__selectors__' in classdict:
-            cls.__selgenerated__ = True
-            # case where __selectors__ is defined locally (but __select__
-            # is in a parent class)
-            selectors = classdict['__selectors__']
-            if len(selectors) == 1:
-                # micro optimization: don't bother with AndSelector if there's
-                # only one selector
-                select = _instantiate_selector(selectors[0])
-            else:
-                select = AndSelector(*selectors)
-            cls.__select__ = select
+        for klass in cls.mro():
+            if klass.__name__ == 'AppRsetObject':
+                continue # the bw compat __selector__ is there
+            klassdict = klass.__dict__
+            if ('__select__' in klassdict and '__selectors__' in klassdict
+                and '__selgenerated__' not in klassdict):
+                raise TypeError("__select__ and __selectors__ can't be used together on class %s" % cls)
+            if '__selectors__' in klassdict and '__selgenerated__' not in klassdict:
+                cls.__selgenerated__ = True
+                # case where __selectors__ is defined locally (but __select__
+                # is in a parent class)
+                selectors = klassdict['__selectors__']
+                if len(selectors) == 1:
+                    # micro optimization: don't bother with AndSelector if there's
+                    # only one selector
+                    select = _instantiate_selector(selectors[0])
+                else:
+                    select = AndSelector(*selectors)
+                cls.__select__ = select
 
 
 class VRegistry(object):