more iface based cleanup fixes tls-sprint
authorsylvain.thenault@logilab.fr
Wed, 18 Feb 2009 15:01:29 +0100
branchtls-sprint
changeset 785 e4f9fa3c891a
parent 784 33db07c66789
child 786 a261fee1bbde
more iface based cleanup fixes
cwvreg.py
--- a/cwvreg.py	Wed Feb 18 13:44:35 2009 +0100
+++ b/cwvreg.py	Wed Feb 18 15:01:29 2009 +0100
@@ -94,11 +94,11 @@
         """register an object but remove it if no entity class implements one of
         the given interfaces
         """
+        self.register(obj, **kwargs)
         if not isinstance(ifaces,  (tuple, list)):
-            self._needs_iface[obj] = frozenset((ifaces,))
+            self._needs_iface[obj] = (ifaces,)
         else:
-            self._needs_iface[obj] = frozenset(ifaces)
-        self.register(obj, **kwargs)
+            self._needs_iface[obj] = ifaces
 
     def register(self, obj, **kwargs):
         if kwargs.get('registryname', obj.__registry__) == 'etypes':
@@ -107,7 +107,7 @@
         # XXX bw compat
         ifaces = use_interfaces(obj)
         if ifaces:
-            self._needs_iface[obj] = frozenset(ifaces)
+            self._needs_iface[obj] = ifaces
         
     def register_objects(self, path, force_reload=None):
         """overriden to remove objects requiring a missing interface"""
@@ -124,7 +124,10 @@
                 for cls in classes:
                     for iface in cls.__implements__:
                         interfaces.update(expand_parent_classes(iface))
+                    interfaces.update(expand_parent_classes(cls))
             for obj, ifaces in self._needs_iface.items():
+                ifaces = frozenset(isinstance(iface, basestring) and self.etype_class(iface) or iface
+                                   for iface in ifaces)
                 if not ifaces & interfaces:
                     self.debug('kicking vobject %s (unsupported interface)', obj)
                     self.unregister(obj)