[Zope3-checkins] CVS: Packages/ZConfig - schema.py:1.1.2.38

Fred L. Drake, Jr. fred@zope.com
Fri, 3 Jan 2003 13:07:42 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	schema.py 
Log Message:
Start support for configuration packages.  This will be needed to allow
schema extensions to be installed by third-party packages (such as
DirectoryStorage).

The meat of it is not there, but some of the framework and checks are in,
with the relevant tests added.


=== Packages/ZConfig/schema.py 1.1.2.37 => 1.1.2.38 ===
--- Packages/ZConfig/schema.py:1.1.2.37	Fri Jan  3 12:05:21 2003
+++ Packages/ZConfig/schema.py	Fri Jan  3 13:07:09 2003
@@ -114,15 +114,24 @@
 
     def start_import(self, attrs):
         src = attrs.get("src", "").strip()
-        if not src:
-            self.error("import src may not be omitted or empty")
-        src = url.urljoin(self._url, src)
-        src, fragment = url.urldefrag(src)
-        if fragment:
-            self.error("import src many not include a fragment identifier")
-        schema = self._loader.loadURL(src)
-        for n in schema.gettypenames():
-            self._schema.addtype(schema.gettype(n))
+        pkg = attrs.get("package", "").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:
+            src = url.urljoin(self._url, src)
+            src, fragment = url.urldefrag(src)
+            if fragment:
+                self.error("import src many not include a fragment identifier")
+            urls = [src]
+        else:
+            raise NotImpementedError(
+                "<import package='...'/> not yet implemented")
+        for s in urls:
+            schema = self._loader.loadURL(s)
+            for n in schema.gettypenames():
+                self._schema.addtype(schema.gettype(n))
 
     def end_import(self):
         pass