[Zodb-checkins] CVS: Zope3/src/ZConfig - loader.py:1.20 schema.py:1.22

Fred L. Drake, Jr. fred at zope.com
Thu Jul 10 15:40:11 EDT 2003


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

Modified Files:
	loader.py schema.py 
Log Message:
Added "file" attribute to the "import" element; this allows a package to
provide more than one ZConfig schema component.


=== Zope3/src/ZConfig/loader.py 1.19 => 1.20 ===
--- Zope3/src/ZConfig/loader.py:1.19	Thu Jul 10 11:32:18 2003
+++ Zope3/src/ZConfig/loader.py	Thu Jul 10 14:39:34 2003
@@ -137,7 +137,7 @@
 
     # schema parser support API
 
-    def schemaComponentSource(self, package):
+    def schemaComponentSource(self, package, file):
         parts = package.split(".")
         if not parts:
             raise ZConfig.SchemaError(
@@ -146,9 +146,10 @@
             # '' somewhere in the package spec; still illegal
             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)
-            fn = os.path.join(dirname, "component.xml")
+            fn = os.path.join(dirname, file)
             if os.path.exists(fn):
                 break
         else:
@@ -178,7 +179,8 @@
 
     def startSection(self, parent, type, name, delegatename):
         if delegatename:
-            raise NotImpementedError("section delegation is not yet supported")
+            raise NotImpementedError(
+                "section delegation is not yet supported")
         t = self.schema.gettype(type)
         if t.isabstract():
             raise ZConfig.ConfigurationError(


=== Zope3/src/ZConfig/schema.py 1.21 => 1.22 ===
--- Zope3/src/ZConfig/schema.py:1.21	Thu Jul 10 11:32:18 2003
+++ Zope3/src/ZConfig/schema.py	Thu Jul 10 14:39:34 2003
@@ -13,6 +13,7 @@
 ##############################################################################
 """Parser for ZConfig schemas."""
 
+import os
 import xml.sax
 
 import ZConfig
@@ -279,11 +280,14 @@
     def start_import(self, attrs):
         src = attrs.get("src", "").strip()
         pkg = attrs.get("package", "").strip()
+        file = attrs.get("file", "").strip()
         if not (src or pkg):
             self.error("import must specify either src or package")
         if src and pkg:
             self.error("import may only specify one of src or package")
         if src:
+            if file:
+                self.error("import may not specify file and src")
             src = url.urljoin(self._url, src)
             src, fragment = url.urldefrag(src)
             if fragment:
@@ -292,15 +296,13 @@
             schema = self._loader.loadURL(src)
             for n in schema.gettypenames():
                 self._schema.addtype(schema.gettype(n))
-        elif self._components.has_key(pkg):
-            # already loaded, or in progress
-            pass
         else:
-            src = self._loader.schemaComponentSource(pkg)
-            if not src:
-                self.error("could not locate schema component " + `pkg`)
-            self._components[pkg] = src
-            self.loadComponent(src)
+            if os.path.dirname(file):
+                self.error("file may not include a directory part")
+            src = self._loader.schemaComponentSource(pkg, file)
+            if not self._components.has_key(src):
+                self._components[pkg] = src
+                self.loadComponent(src)
 
     def loadComponent(self, src):
         r = self._loader.openResource(src)




More information about the Zodb-checkins mailing list