[registration] don't crash on import error while initializing the registry and not in debug mode
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 25 Oct 2010 10:23:32 +0200
changeset 6617 120c7ea6e1fa
parent 6616 26587186b856
child 6619 ed5b452506af
[registration] don't crash on import error while initializing the registry and not in debug mode
cwvreg.py
--- a/cwvreg.py	Mon Oct 25 10:20:24 2010 +0200
+++ b/cwvreg.py	Mon Oct 25 10:23:32 2010 +0200
@@ -462,6 +462,7 @@
     def clear(self): pass
     def initialization_completed(self): pass
 
+
 class CubicWebVRegistry(VRegistry):
     """Central registry for the cubicweb instance, extending the generic
     VRegistry with some cubicweb specific stuff.
@@ -559,6 +560,14 @@
         if self.is_reload_needed(path):
             self.reload(path)
 
+    def load_file(self, filepath, modname):
+        try:
+            super(CubicWebVRegistry, self).load_file(filepath, modname)
+        except ImportError:
+            if self.config.debugmode:
+                raise
+            self.exception('failed to load %s from %s', filepath, modname)
+
     def reload(self, path, force_reload=True):
         """modification detected, reset and reload the vreg"""
         CW_EVENT_MANAGER.emit('before-registry-reload')