[vreg] check for identical app objects when replacing
Prevent from weird behaviour when you badly wrote vreg callback
--- a/vregistry.py Thu Jan 20 14:38:53 2011 +0100
+++ b/vregistry.py Fri Jan 21 11:13:40 2011 +0100
@@ -129,6 +129,8 @@
# or simplify by calling unregister then register here
if not isinstance(replaced, basestring):
replaced = classid(replaced)
+ # prevent from misspelling
+ assert obj is not replaced, 'replacing an object by itself: %s' % obj
registered_objs = self.get(class_regid(obj), ())
for index, registered in enumerate(registered_objs):
if classid(registered) == replaced: