[Zodb-checkins] CVS: Zope/lib/python/ZConfig - __init__.py:1.6.2.1 info.py:1.8.2.1 loader.py:1.10.2.1 schema.py:1.11.2.1

Chris McDonough chrism@zope.com
Mon, 13 Jan 2003 20:18:04 -0500


Update of /cvs-repository/Zope/lib/python/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv6546

Modified Files:
      Tag: chrism-install-branch
	__init__.py info.py loader.py schema.py 
Log Message:
Merge ZConfig from HEAD.


=== Zope/lib/python/ZConfig/__init__.py 1.6 => 1.6.2.1 ===
--- Zope/lib/python/ZConfig/__init__.py:1.6	Mon Jan  6 15:02:56 2003
+++ Zope/lib/python/ZConfig/__init__.py	Mon Jan 13 20:17:27 2003
@@ -20,15 +20,6 @@
 from ZConfig.loader import loadSchema, loadSchemaFile
 
 
-def loadURL(url):
-    import Context
-    return Context.Context().loadURL(url)
-
-def loadFile(file, url=None):
-    import Context
-    return Context.Context().loadFile(file, url)
-
-
 class ConfigurationError(Exception):
     def __init__(self, msg):
         self.message = msg


=== Zope/lib/python/ZConfig/info.py 1.8 => 1.8.2.1 ===
--- Zope/lib/python/ZConfig/info.py:1.8	Thu Jan  9 11:34:43 2003
+++ Zope/lib/python/ZConfig/info.py	Mon Jan 13 20:17:27 2003
@@ -368,18 +368,18 @@
 
 
 class SchemaType(SectionType):
-    def __init__(self, name, keytype, valuetype, datatype, handler, url,
+    def __init__(self, keytype, valuetype, datatype, handler, url,
                  registry):
-        SectionType.__init__(self, name, keytype, valuetype, datatype,
+        SectionType.__init__(self, None, keytype, valuetype, datatype,
                              registry, {})
         self.handler = handler
         self.url = url
 
     def addtype(self, typeinfo):
-        n = typeinfo.name.lower()
+        n = typeinfo.name
         if self._types.has_key(n):
             raise ZConfig.SchemaError("type name cannot be redefined: "
-                                             + `typeinfo.name`)
+                                      + `typeinfo.name`)
         self._types[n] = typeinfo
 
     def allowUnnamed(self):


=== Zope/lib/python/ZConfig/loader.py 1.10 => 1.10.2.1 ===
--- Zope/lib/python/ZConfig/loader.py:1.10	Thu Jan  9 17:29:35 2003
+++ Zope/lib/python/ZConfig/loader.py	Mon Jan 13 20:17:27 2003
@@ -48,8 +48,8 @@
     def __init__(self):
         pass
 
-    def createResource(self, file, url, fragment=None):
-        return Resource(file, url, fragment)
+    def createResource(self, file, url):
+        return Resource(file, url)
 
     def loadURL(self, url):
         url = self.normalizeURL(url)
@@ -77,30 +77,18 @@
         # change and provide the cached resource when the remote
         # resource is not accessible.
         url = str(url)
-        parts = urlsplit(url)
-        fragment = parts[-1]
-        if fragment:
-            parts = list(parts)
-            parts[-1] = ''
-            url = urlunsplit(tuple(parts))
         file = urllib2.urlopen(url)
-        return self.createResource(file, url, fragment or None)
+        return self.createResource(file, url)
 
     def normalizeURL(self, url):
         if os.path.exists(url):
             url = "file://" + urllib.pathname2url(os.path.abspath(url))
-        else:
-            url = urlnormalize(url)
-        if url and not self.allowFragments():
-            url, fragment = urldefrag(url)
-            if fragment:
-                raise ZConfig.ConfigurationError(
-                    "fragment identifiers are not supported")
+        url, fragment = urldefrag(url)
+        if fragment:
+            raise ZConfig.ConfigurationError(
+                "fragment identifiers are not supported")
         return url
 
-    def allowFragments(self):
-        return False
-
 
 def _url_from_file(file):
     name = getattr(file, "name", None)
@@ -125,17 +113,11 @@
             from ZConfig.schema import parseResource
             schema = parseResource(resource, self.registry, self)
             self._cache[resource.url] = schema
-        if resource.fragment:
-            type = self.registry.get("basic-key")(resource.fragment)
-            schema = schema.gettype(type)
         return schema
 
-    def allowFragments(self):
-        return True
-
     # schema parser support API
 
-    def schemaPackageInfo(self, package):
+    def schemaComponentInfo(self, package):
         parts = package.split(".")
         if not parts:
             raise ZConfig.SchemaError(
@@ -145,7 +127,7 @@
             raise ZConfig.SchemaError(
                 "illegal schema component name: " + `package`)
         for dir in sys.path:
-            dirname = os.path.join(dir, *parts)
+            dirname = os.path.join(os.path.abspath(dir), *parts)
             fn = os.path.join(dirname, "component.xml")
             if os.path.exists(fn):
                 break
@@ -246,10 +228,9 @@
 
 
 class Resource:
-    def __init__(self, file, url, fragment=None):
+    def __init__(self, file, url):
         self.file = file
         self.url = url
-        self.fragment = fragment
 
     def close(self):
         if self.file is not None:


=== Zope/lib/python/ZConfig/schema.py 1.11 => 1.11.2.1 ===
--- Zope/lib/python/ZConfig/schema.py:1.11	Thu Jan  9 00:42:28 2003
+++ Zope/lib/python/ZConfig/schema.py	Mon Jan 13 20:17:27 2003
@@ -257,7 +257,7 @@
             # already loaded, or in progress
             pass
         else:
-            pi = self._loader.schemaPackageInfo(pkg)
+            pi = self._loader.schemaComponentInfo(pkg)
             if not pi:
                 self.error("could not locate schema component " + `pkg`)
             self._components[pkg] = pi
@@ -427,15 +427,9 @@
         self.push_prefix(attrs)
         handler = self.get_handler(attrs)
         keytype, valuetype, datatype = self.get_sect_typeinfo(attrs)
-        name = attrs.get("type")
-        if name is not None:
-            name = self.basic_key(name)
-        self._schema = info.SchemaType(name, keytype, valuetype, datatype,
+        self._schema = info.SchemaType(keytype, valuetype, datatype,
                                        handler, self._url, self._registry)
         self._localtypes = self._schema._types
-        if name is not None:
-            # XXX circular reference
-            self._schema.addtype(self._schema)
         self._stack = [self._schema]
 
     def end_schema(self):