factorized impl tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 17 Feb 2009 17:31:01 +0100
branchtls-sprint
changeset 673 64c50cb17d70
parent 672 bfd01026ada8
child 679 d70fb8c9e369
factorized impl
vregistry.py
--- a/vregistry.py	Tue Feb 17 17:26:28 2009 +0100
+++ b/vregistry.py	Tue Feb 17 17:31:01 2009 +0100
@@ -289,13 +289,16 @@
                 break
     
     def register_and_replace(self, obj, replaced, registryname=None):
+        if hasattr(replaced, 'classid'):
+            replaced = replaced.classid()
         registryname = registryname or obj.__registry__
         registry = self.registry(registryname)
         registered_objs = registry[obj.id]
         for index, registered in enumerate(registered_objs):
             if registered.classid() == replaced:
-                registry[obj.id][index] = obj
-                self._registered['%s.%s' % (obj.__module__, obj.id)] = obj                
+                del registry[obj.id][index]
+                break
+        self.register(obj, registryname=registryname)
 
     # dynamic selection methods ###############################################