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

Fred L. Drake, Jr. fred@zope.com
Fri, 13 Dec 2002 00:05:44 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	loader.py 
Log Message:
Add support for extracting just one portion of a schema by name.


=== Packages/ZConfig/loader.py 1.1.2.10 => 1.1.2.11 ===
--- Packages/ZConfig/loader.py:1.1.2.10	Thu Dec 12 17:50:48 2002
+++ Packages/ZConfig/loader.py	Fri Dec 13 00:05:43 2002
@@ -77,10 +77,20 @@
 
 
 class SchemaLoader(BaseLoader):
+    _fragment = None
+
+    def normalizeURL(self, url):
+        if url:
+            url, self._fragment = urlparse.urldefrag(url)
+        return BaseLoader.normalizeURL(self, url)
+
     def loadResource(self, resource):
         from ZConfig.schema import SchemaParser
         parser = SchemaParser()
-        return parser.parseStream(resource.file)
+        schema = parser.parseStream(resource.file)
+        if self._fragment:
+            schema = schema.gettype(self._fragment)
+        return schema
 
 
 class ConfigLoader(BaseLoader):