fix exception class, simply print warning when calling register_and_replace with an unregistered view
--- a/vregistry.py Tue May 26 17:27:43 2009 +0200
+++ b/vregistry.py Tue May 26 18:22:24 2009 +0200
@@ -237,7 +237,7 @@
# XXX automatic reloading management
try:
registry[obj.id].remove(registered)
- except ValueError:
+ except KeyError:
self.warning('can\'t remove %s, no id %s in the %s registry',
removed_id, obj.id, registryname)
except ValueError:
@@ -254,11 +254,14 @@
replaced = replaced.classid()
registryname = registryname or obj.__registry__
registry = self.registry(registryname)
- registered_objs = registry[obj.id]
+ registered_objs = registry.get(obj.id, ())
for index, registered in enumerate(registered_objs):
if registered.classid() == replaced:
del registry[obj.id][index]
break
+ else:
+ self.warning('trying to replace an unregistered view %s by %s',
+ replaced, obj)
self.register(obj, registryname=registryname)
# dynamic selection methods ###############################################