[Zodb-checkins] CVS: Packages/ZConfig - loader.py:1.10

Fred L. Drake, Jr. fred@zope.com
Thu, 9 Jan 2003 17:30:08 -0500


Update of /cvs-repository/Packages/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv794

Modified Files:
	loader.py 
Log Message:
Make schema components get searched on sys.path:  Since these bind to code
via the datatype attributes, this makes quite a bit of sense after all.


=== Packages/ZConfig/loader.py 1.9 => 1.10 ===
--- Packages/ZConfig/loader.py:1.9	Thu Jan  9 11:34:43 2003
+++ Packages/ZConfig/loader.py	Thu Jan  9 17:29:35 2003
@@ -31,9 +31,6 @@
     False = 0
 
 
-LIBRARY_DIR = os.path.join(sys.prefix, "lib", "zconfig")
-
-
 def loadSchema(url):
     return SchemaLoader().loadURL(url)
 
@@ -114,15 +111,12 @@
 
 
 class SchemaLoader(BaseLoader):
-    def __init__(self, registry=None, library=None):
+    def __init__(self, registry=None):
         if registry is None:
             registry = datatypes.Registry()
         BaseLoader.__init__(self)
         self.registry = registry
         self._cache = {}
-        if library is None:
-            library = LIBRARY_DIR
-        self._library = library
 
     def loadResource(self, resource):
         if resource.url and self._cache.has_key(resource.url):
@@ -150,9 +144,12 @@
             # '' somewhere in the package spec; still illegal
             raise ZConfig.SchemaError(
                 "illegal schema component name: " + `package`)
-        dirname = os.path.join(self._library, *parts)
-        fn = os.path.join(dirname, "component.xml")
-        if not os.path.exists(fn):
+        for dir in sys.path:
+            dirname = os.path.join(dir, *parts)
+            fn = os.path.join(dirname, "component.xml")
+            if os.path.exists(fn):
+                break
+        else:
             raise ZConfig.SchemaError(
                 "schema component not found: " + `package`)
         url = "file://" + urllib.pathname2url(fn)