merge oldstable
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 17 Mar 2011 12:14:58 +0100
brancholdstable
changeset 7092 076c5be627f6
parent 7090 d9e6e79e023a (diff)
parent 7086 0d63937991a5 (current diff)
child 7093 dccc22c60473
merge
--- a/devtools/__init__.py	Wed Mar 16 09:45:57 2011 +0100
+++ b/devtools/__init__.py	Thu Mar 17 12:14:58 2011 +0100
@@ -698,9 +698,14 @@
 
 HANDLERS = {}
 
-def register_handler(handlerkls):
+def register_handler(handlerkls, overwrite=False):
     assert handlerkls is not None
-    HANDLERS[handlerkls.DRIVER] = handlerkls
+    if overwrite or handlerkls.DRIVER not in HANDLERS:
+        HANDLERS[handlerkls.DRIVER] = handlerkls
+    else:
+        msg = "%s: Handler already exists use overwrite if it's intended\n"
+              "(existing handler class is %r)"
+        raise ValueError(msg % (handlerkls.DRIVER, HANDLERS[handlerkls.DRIVER]))
 
 register_handler(PostgresTestDataBaseHandler)
 register_handler(SQLiteTestDataBaseHandler)