vregistry.py
branchtls-sprint
changeset 673 64c50cb17d70
parent 668 61b2328f9ed9
child 682 d95936d6ce5c
--- 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 ###############################################