Today it's very hard to debug ImportErrors raise inside modules referenced through a zcml directive, because the ImportError is swallowed an no traceback comes back to the user. Just a ConfigurationError: ('Invalid value for', 'class', "Couldn't import some.class, cannot import name somename")
which doesn't point anywhere useful.

I'd like to modify zope.configuration.config to something like:

        try:
            mod = __import__(mname, *_import_chickens)
        except ImportError, v:
+            if sys.exc_info()[2].tb_next is not None:
+                # ImportError was caused deeper
+                raise
            raise ConfigurationError, (
                "Couldn't import %s, %s" % (mname, v)
                ), sys.exc_info()[2]

Instead of the simpler code that was there (this nice trick is by PJE, and is used ).

Also I need to fix zope.configuration.xmlconfig, today it has a bare except:

        try:
            self.context.begin(name, data, info)
        except:
            if self.testing:
                raise
            raise ZopeXMLConfigurationError, (
                info, sys.exc_info()[0], sys.exc_info()[1]
                ), sys.exc_info()[2]

Shouldn't it just catch ConfigurationError?

With both changes I get much nicer error report: just a traceback with the correct info.

Florent

--
Florent Guillaume, Nuxeo (Paris, France)   Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]


_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to