[Zope3-checkins] SVN: Zope3/trunk/src/zope/configuration/xmlconfig.py Fix code that was causing a test failure when an older version zope.app was installed on the python path.

Brian Sutherland jinty at web.de
Thu Apr 5 05:40:23 EDT 2007


Log message for revision 74015:
  Fix code that was causing a test failure when an older version zope.app was installed on the python path.

Changed:
  U   Zope3/trunk/src/zope/configuration/xmlconfig.py

-=-
Modified: Zope3/trunk/src/zope/configuration/xmlconfig.py
===================================================================
--- Zope3/trunk/src/zope/configuration/xmlconfig.py	2007-04-04 19:56:56 UTC (rev 74014)
+++ Zope3/trunk/src/zope/configuration/xmlconfig.py	2007-04-05 09:40:20 UTC (rev 74015)
@@ -500,15 +500,24 @@
     # This is a backward-compatibility support for old site.conf
 
     if package and (package.__name__ == 'zope.app'):
-        dirpath, filename = os.path.split(file)
-        file = os.path.join(dirpath, "zcmlfiles", filename)
-        import warnings
-        warnings.warn('In configuration file: %s '
-                      'replace: <include package="zope.app" /> '
-                      'with: <include package="zope.app.zcmlfiles" /> '
-                      'This will go away in Zope 3.6.' % os.path.abspath(file),
-                      DeprecationWarning,
-                      2)
+        try:
+            import zope.app.zcmlfiles
+        except ImportError:
+            pass # maybe this is an old zope without zope.app.zcmlfiles
+        else:
+            dirpath, filename = os.path.split(file)
+            # be careful, because zope.app is a namespace package
+            # we can't assume that zcmlfiles is a subdirectory of the 
+            # zope.app package
+            dirpath = os.path.dirname(zope.app.zcmlfiles.__file__)
+            file = os.path.join(dirpath, filename)
+            import warnings
+            warnings.warn('In configuration file: %s '
+                          'replace: <include package="zope.app" /> '
+                          'with: <include package="zope.app.zcmlfiles" /> '
+                          'This will go away in Zope 3.6.' % os.path.abspath(file),
+                          DeprecationWarning,
+                          2)
 
     # This is a tad tricky. We want to behave as a grouping directive.
 



More information about the Zope3-Checkins mailing list