[Zope-Checkins] CVS: Zope3/src/ZConfig - loader.py:1.22

Fred L. Drake, Jr. fred at zope.com
Fri Oct 3 12:32:41 EDT 2003


Update of /cvs-repository/Zope3/src/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv1758

Modified Files:
	loader.py 
Log Message:
When loading schema components, use the Python import mechanism to load the
package; we only need to look for the schema information within that.


=== Zope3/src/ZConfig/loader.py 1.21 => 1.22 ===
--- Zope3/src/ZConfig/loader.py:1.21	Wed Sep 10 16:14:01 2003
+++ Zope3/src/ZConfig/loader.py	Fri Oct  3 12:32:10 2003
@@ -150,15 +150,19 @@
             raise ZConfig.SchemaError(
                 "illegal schema component name: " + `package`)
         file = file or "component.xml"
-        for dir in sys.path:
-            dirname = os.path.join(os.path.abspath(dir), *parts)
+        __import__(package)
+        pkg = sys.modules[package]
+        if not hasattr(pkg, "__path__"):
+            raise ZConfig.SchemaError(
+                "import name does not refer to a package: " + `package`)
+        for dir in pkg.__path__:
+            dirname = os.path.abspath(dir)
             fn = os.path.join(dirname, file)
             if os.path.exists(fn):
-                break
+                return "file://" + urllib.pathname2url(fn)
         else:
             raise ZConfig.SchemaError(
                 "schema component not found: " + `package`)
-        return "file://" + urllib.pathname2url(fn)
 
 
 class ConfigLoader(BaseLoader):




More information about the Zope-Checkins mailing list