[Zodb-checkins] CVS: Packages/ZConfig - __init__.py:1.3.10.1 loader.py:1.1.2.2
Fred L. Drake, Jr.
fred@zope.com
Tue, 10 Dec 2002 11:28:04 -0500
Update of /cvs-repository/Packages/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv3304
Modified Files:
Tag: zconfig-schema-devel-branch
__init__.py loader.py
Log Message:
Add high-level schema loader and convenience functions.
=== Packages/ZConfig/__init__.py 1.3 => 1.3.10.1 ===
--- Packages/ZConfig/__init__.py:1.3 Thu Dec 5 00:17:45 2002
+++ Packages/ZConfig/__init__.py Tue Dec 10 11:28:03 2002
@@ -25,3 +25,11 @@
def loadfile(file, url=None):
import Context
return Context.Context().loadfile(file, url)
+
+def loadschema(url):
+ import loader
+ return loader.SchemaLoader().load(url)
+
+def loadschemafile(file, url=None):
+ import loader
+ return loader.SchemaLoader().loadfile(file, url)
=== Packages/ZConfig/loader.py 1.1.2.1 => 1.1.2.2 ===
--- Packages/ZConfig/loader.py:1.1.2.1 Tue Dec 10 10:57:19 2002
+++ Packages/ZConfig/loader.py Tue Dec 10 11:28:03 2002
@@ -54,6 +54,24 @@
return None
+class SchemaLoader(BaseLoader):
+ def load(self, url):
+ url = self.normalizeURL(url)
+ r = self.openResource(url)
+ return self._load_resource(r)
+
+ def loadfile(self, file, url=None):
+ if not url:
+ url = self._url_from_file(file)
+ r = self.createResource(file, url)
+ return self._load_resource(r)
+
+ def _load_resource(self, resource):
+ from SchemaParser import SchemaParser
+ parser = SchemaParser()
+ return parser.parseStream(resource.file)
+
+
class Resource:
def __init__(self, file, url):
self.file = file