Hi,

I ran into a bit of a strange problem recently while using a custom
importer (installed by reassigning __builtin__.__import__).  The first
thing my custom importer does is call the original __import__ to get the
module being imported from.  What was strange is that when I used it to
import Zope code it blew up (in the call to the original importer)
complaining that 'zope.app.layers.zope.app.rotterdam' couldn't be
imported.  I'm not sure of this, but am wondering if the problem is
because the check at zope/configuration/config.py:184 fails because my
importer adds a layer to the call stack.  The check is:

            if sys.exc_info()[2].tb_next is not None:
                # ImportError was caused deeper
                raise

The following patch has solved the problem for me:

Index: src/zope/app/component/back35.py
===================================================================
--- src/zope/app/component/back35.py    (revision 73358)
+++ src/zope/app/component/back35.py    (working copy)
@@ -774,7 +774,7 @@

         try:
             value = self.context.resolve('zope.app.layers.'+name)
-        except (ConfigurationError, ValueError), v:
+        except (ImportError, ConfigurationError, ValueError), v:
             try:
                 value = self.context.resolve(name)
             except ConfigurationError, v:

I'm not sure it's the right fix but thought I'd post it here anyway.

Thanks,
J.
_______________________________________________
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